Config is a lightweight pluggable dynamic config package without useless dependencies. Base on forked from github.com/go-micro/go-micro/config.
- dynamic loading
- pluggable sources
- mergeable config
- observe changes
- sane defaults
load config from env
, flag
and file
.
if err := config.Load(env.NewSource()); err != nil {
return err
}
if err := config.Load(flag.NewSource(flag.IncludeUnset(true))); err != nil {
return err
}
configFile := "config_file.json"
if err := config.Load(file.NewSource(file.WithPath(configFile))); err != nil {
return err
}
get config to struct
func Scan(v any, path ...string) error {
return config.Get(path...).Scan(v)
}
See the License File.