Documentation
¶
Overview ¶
Package env implements a koanf.Provider that reads environment variables as conf maps.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Env ¶
type Env struct {
// contains filtered or unexported fields
}
Env implements an environment variables provider.
func Provider ¶
Provider returns an environment variables provider that returns a nested map[string]interface{} of environment variable where the nesting hierarchy of keys is defined by delim. For instance, the delim "." will convert the key `parent.child.key: 1` to `{parent: {child: {key: 1}}}`.
If prefix is specified (case-sensitive), only the env vars with the prefix are captured. cb is an optional callback that takes a string and returns a string (the env variable name) in case transformations have to be applied, for instance, to lowercase everything, strip prefixes and replace _ with . etc. If the callback returns an empty string, the variable will be ignored.
func ProviderWithValue ¶ added in v0.14.0
func ProviderWithValue(prefix, delim string, cb func(key string, value string) (string, interface{})) *Env
ProviderWithValue works exactly the same as Provider except the callback takes a (key, value) with the variable name and value and allows you to modify both. This is useful for cases where you may want to return other types like a string slice instead of just a string.