Documentation ¶
Index ¶
- func Get(names ...string) (map[string]string, error)
- func GetOrDefaultBool(envVar string, defaultValue bool) bool
- func GetOrDefaultInt(envVar string, defaultValue int) int
- func GetOrDefaultSecond(envVar string, defaultValue time.Duration) time.Duration
- func GetOrDefaultString(envVar, defaultValue string) string
- func GetOrFile(envVar string) string
- func GetWithFallback(groups ...[]string) (map[string]string, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetOrDefaultBool ¶
GetOrDefaultBool returns the given environment variable value as a boolean. Returns the default if the envvar cannot be coopered to a boolean, or is not found.
func GetOrDefaultInt ¶
GetOrDefaultInt returns the given environment variable value as an integer. Returns the default if the envvar cannot be coopered to an int, or is not found.
func GetOrDefaultSecond ¶
GetOrDefaultSecond returns the given environment variable value as an time.Duration (second). Returns the default if the envvar cannot be coopered to an int, or is not found.
func GetOrDefaultString ¶
GetOrDefaultString returns the given environment variable value as a string. Returns the default if the envvar cannot be find.
func GetOrFile ¶
GetOrFile Attempts to resolve 'key' as an environment variable. Failing that, it will check to see if '<key>_FILE' exists. If so, it will attempt to read from the referenced file to populate a value.
func GetWithFallback ¶
GetWithFallback Get environment variable values The first name in each group is use as key in the result map
// LEGO_ONE="ONE" // LEGO_TWO="TWO" env.GetWithFallback([]string{"LEGO_ONE", "LEGO_TWO"}) // => "LEGO_ONE" = "ONE"
----
// LEGO_ONE="" // LEGO_TWO="TWO" env.GetWithFallback([]string{"LEGO_ONE", "LEGO_TWO"}) // => "LEGO_ONE" = "TWO"
----
// LEGO_ONE="" // LEGO_TWO="" env.GetWithFallback([]string{"LEGO_ONE", "LEGO_TWO"}) // => error
Types ¶
This section is empty.