configutils

package
v0.0.4-8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 1, 2025 License: MIT Imports: 14 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DELIM string = "."

Functions

This section is empty.

Types

type Config

type Config struct {
	Layer      *koanf.Koanf
	ReloadFunc func(string)
}

func New

func New() *Config

Create a New Config

func NewWith

func NewWith(delim string, reloadFunc func(string)) *Config

Create a New Config with Args

func (Config) ApplyTransformFuncs

func (config Config) ApplyTransformFuncs(id string, structSchema any, path string, funcs map[string]func(string, any) (string, any))

Apply Transform funcs based on `transform` and `childtransform` in struct schema

func (*Config) Load

func (config *Config) Load(data any, path string) error

Load data into Config path

func (*Config) LoadDir

func (config *Config) LoadDir(path string, dir string, ext string, parser koanf.Parser) error

Load files inside of dir with parser into Config path (default: ext="")

func (*Config) LoadEnv

func (config *Config) LoadEnv(transformFunc func(key string, value string) (string, any)) (*env.Env, error)

Load environment into Config with transformFunc

func (*Config) LoadFile

func (config *Config) LoadFile(path string, parser koanf.Parser) (*file.File, error)

Load file with parser into Config

func (*Config) MergeLayers

func (config *Config) MergeLayers(layers ...*koanf.Koanf) error

Merge layers into Config

func (*Config) OnReload added in v0.0.2

func (config *Config) OnReload(reloadFunc func(string))

Add OnReload func

func (*Config) TemplateConfig

func (config *Config) TemplateConfig() error

Template Config with environment variables

func (*Config) WatchFile

func (config *Config) WatchFile(fileProvider *file.File, path string)

Watch file with file provider

type TransformTarget

type TransformTarget struct {
	OutputKey      string
	Transform      string
	ChildTransform string
	Value          any
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL