Releases: offen/envconfig
Releases · offen/envconfig
1.5.0
Exposing Lookup
to the user enables them to use a custom LookupEnv
function.
This way, any custom logic like the _FILE convention mentioned in kelseyhightower#130 can be supported on the application side.
Example taken and adapted from offen/docker-volume-backup:
envconfig.Lookup = func(key string) (string, bool) {
location, ok := os.LookupEnv(key + "_FILE")
if ok {
contents, err := os.ReadFile(location)
if err != nil {
return "", false
}
return string(contents), true
}
return os.LookupEnv(key)
}
if err := envconfig.Process("", &config); err != nil {
panic(err)
}
...