Skip to content

koanfenv provides koanf callbacks that translate environment variables to koanf keys.

License

Notifications You must be signed in to change notification settings

dochang/koanfenv

Repository files navigation

koanfenv

CI CircleCI codecov Go Reference

koanfenv provides callbacks which convert environment variables to koanf keys. These callbacks are used for env.Provider .

Usage

config := struct{
	Foo1 string `koanf:"foo1" env:"APP_FOO1"`
}{}

k := koanf.New(".")
if err := k.Load(env.Provider("APP_", ".", koanfenv.ByStruct(&config)), nil); err != nil {
	log.Fatal(err)
}
m := map[string]string{
	"APP_FOO1": "foo1",
}

k := koanf.New(".")
if err := k.Load(env.Provider("APP_", ".", koanfenv.ByMap(m)), nil); err != nil {
	log.Fatal(err)
}

License

MIT

About

koanfenv provides koanf callbacks that translate environment variables to koanf keys.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages