Documentation ¶
Index ¶
- func Get(names ...string) (map[string]string, error)
- func GetOneWithFallback[T any](main string, defaultValue T, fn func(string) (T, error), names ...string) T
- 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 string, defaultValue string) string
- func GetOrFile(envVar string) string
- func GetWithFallback(groups ...[]string) (map[string]string, error)
- func ParseSecond(s string) (time.Duration, error)
- func ParseString(s string) (string, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetOneWithFallback ¶
func GetOrDefaultBool ¶
GetOrDefaultBool returns the given environment variable value as a boolean. Returns the default if the env var 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 env var cannot be coopered to an int, or is not found.
func GetOrDefaultSecond ¶
GetOrDefaultSecond returns the given environment variable value as a time.Duration (second). Returns the default if the env var 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 env var cannot be found.
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.
case 1:
// LEGO_ONE="ONE" // LEGO_TWO="TWO" env.GetWithFallback([]string{"LEGO_ONE", "LEGO_TWO"}) // => "LEGO_ONE" = "ONE"
case 2:
// LEGO_ONE="" // LEGO_TWO="TWO" env.GetWithFallback([]string{"LEGO_ONE", "LEGO_TWO"}) // => "LEGO_ONE" = "TWO"
case 3:
// LEGO_ONE="" // LEGO_TWO="" env.GetWithFallback([]string{"LEGO_ONE", "LEGO_TWO"}) // => error
func ParseSecond ¶
ParseSecond parses env var value (string) to a second (time.Duration).
func ParseString ¶
ParseString parses env var value (string) to a string but throws an error when the string is empty.
Types ¶
This section is empty.