Documentation
¶
Overview ¶
Package getenv provide the implementation of a LookupEnv pattern with default value handling
Index ¶
- func Bool(key string, defaultValue bool) bool
- func Int(key string, defaultValue int) int
- func Int64(key string, defaultValue int64) int64
- func Int64Array(key string, defaultValue []int64) []int64
- func IntArray(key string, defaultValue []int) []int
- func MustGetString(key string) string
- func String(key string, defaultValue string) string
- func TimeDuration(key string, defaultValue time.Duration) time.Duration
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Bool ¶
Bool returns the bool value of the environment variable named by the key, or defaultValue if the environment variable is not set. It accepts 1, t, T, TRUE, true, True, 0, f, F, FALSE, false, False. Any other value returns default value.
func Int ¶
Int returns the int value of the environment variable named by the key, or defaultValue if the environment variable is not set.
func Int64 ¶
Int64 returns the int64 value of the environment variable named by the key, or defaultValue if the environment variable is not set.
func Int64Array ¶ added in v0.0.6
Int64Array returns an array of 64 bit integers from the environment variable by the key, or the default value if the environment variable is not set. It accepts any array of int64 value as long as the array is in a string "[56, 8, 1]" Brackets are optional and whitespace will be trimmed. Any other value returns default value.
func IntArray ¶ added in v0.0.2
IntArray returns an array of integers from the environment variable by the key, or the default value if the environment variable is not set. It accepts any array of int value as long as the array is in a string "[56, 8, 1]" Brackets are optional and whitespace will be trimmed. Any other value returns default value.
func MustGetString ¶ added in v0.0.5
MustGetString returns the string value of the environment variable named by the key, or panics if the environment variable is not set.
func String ¶
String returns the string value of the environment variable named by the key, or defaultValue if the environment variable is not set.
func TimeDuration ¶
TimeDuration returns the time.Duration value of the environment variable named by the key, or defaultValue if the environment variable is not set. If the value is numeric, it assumes it is a nanosecond number. Otherwise, it parses it according to https://pkg.go.dev/time#ParseDuration
Types ¶
This section is empty.