Documentation
¶
Overview ¶
Package defenv contains methods for extracting environments variables.
There are two types of methods in a package: ordinary and strict. If there is no environment variable, or if a parsing error occurs, ordinary methods return a default value.
value := defenv.Int("WORKER_NUMBER", 8)
Unlike ordinary methods, strict methods return an error when parsing fails.
value, err := defenv.IntStrict("WORKER_NUMBER", 8)
Index ¶
- func Bool(name string, defaultValue bool) bool
- func BoolStrict(name string, defaultValue bool) (bool, error)
- func Duration(name string, defaultValue time.Duration) time.Duration
- func DurationStrict(name string, defaultValue time.Duration) (time.Duration, error)
- func Float64(name string, defaultValue float64) float64
- func Float64Strict(name string, defaultValue float64) (float64, error)
- func Int(name string, defaultValue int) int
- func Int64(name string, defaultValue int64) int64
- func Int64Strict(name string, defaultValue int64) (int64, error)
- func IntStrict(name string, defaultValue int) (int, error)
- func String(name, defaultValue string) string
- func Uint(name string, defaultValue uint) uint
- func Uint64(name string, defaultValue uint64) uint64
- func Uint64Strict(name string, defaultValue uint64) (uint64, error)
- func UintStrict(name string, defaultValue uint) (uint, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Bool ¶
Bool extracts bool value from environment variable named name and returns defaultValue if it is absent or can not be parsed
func BoolStrict ¶
BoolStrict extracts bool value from environment variable named name and returns defaultValue if it is absent. If the environment variable can not be parsed, the method returns an error
func Duration ¶
Duration extracts time.Duration value from environment variable named name and returns defaultValue if it is absent or can not be parsed
func DurationStrict ¶
DurationStrict extracts time.Duration value from environment variable named name and returns defaultValue if it is absent. If the environment variable can not be parsed, the method returns an error
func Float64 ¶
Float64 extracts float64 value from environment variable named name and returns defaultValue if it is absent or can not be parsed
func Float64Strict ¶
Float64Strict extracts float64 value from environment variable named name and returns defaultValue if it is absent. If the environment variable can not be parsed, the method returns an error
func Int ¶
Int extracts int value from environment variable named name and returns defaultValue if it is absent or can not be parsed
func Int64 ¶
Int64 extracts int64 value from environment variable named name and returns defaultValue if it is absent or can not be parsed
func Int64Strict ¶
Int64Strict extracts int64 value from environment variable named name and returns defaultValue if it is absent. If the environment variable can not be parsed, the method returns an error
func IntStrict ¶
IntStrict extracts int value from environment variable named name and returns defaultValue if it is absent. If the environment variable can not be parsed, the method returns an error
func String ¶
String extracts string value from environment variable named name and returns defaultValue if it is absent or can not be parsed
func Uint ¶
Uint extracts uint value from environment variable named name and returns defaultValue if it is absent or can not be parsed
func Uint64 ¶
Uint64 extracts uint64 value from environment variable named name and returns defaultValue if it is absent or can not be parsed
func Uint64Strict ¶
Uint64Strict extracts uint64 value from environment variable named name and returns defaultValue if it is absent. If the environment variable can not be parsed, the method returns an error
Types ¶
This section is empty.