Documentation ¶
Overview ¶
Package config provides a wrapper around koanf.
Index ¶
- Constants
- func Add(key string, value interface{}, description string, opts ...Option)
- func All() map[string]interface{}
- func Bool(path string) bool
- func BoolMap(path string) map[string]bool
- func Bools(path string) []bool
- func Bytes(path string) []byte
- func Duration(path string) time.Duration
- func Exists(path string) bool
- func Float64(path string) float64
- func Float64Map(path string) map[string]float64
- func Float64s(path string) []float64
- func Get(path string) interface{}
- func Int(path string) int
- func Int64(path string) int64
- func Int64Map(path string) map[string]int64
- func Int64s(path string) []int64
- func IntMap(path string) map[string]int
- func Ints(path string) []int
- func Load()
- func String(path string) string
- func StringMap(path string) map[string]string
- func Strings(path string) []string
- func Time(path, layout string) time.Time
- func Unmarshal(o interface{}) error
- func UnmarshalWithPath(path string, o interface{}) error
- type Config
- type Option
- type Options
Constants ¶
const ConfArgument = "conf"
const ConfEnvironment = "CONF"
Variables ¶
This section is empty.
Functions ¶
func Bool ¶
Bool returns the bool value of a given key path or false if the path does not exist or if the value is not a valid bool representation. Accepted string representations of bool are the ones supported by strconv.ParseBool.
func BoolMap ¶
BoolMap returns the map[string]bool value of a given key path or an empty map[string]bool if the path does not exist or if the value is not a valid bool map.
func Bools ¶
Bools returns the []bool slice value of a given key path or an empty []bool slice if the path does not exist or if the value is not a valid bool slice.
func Bytes ¶
Bytes returns the []byte value of a given key path or an empty []byte slice if the path does not exist or if the value is not a valid string.
func Duration ¶
Duration returns the time.Duration value of a given key path assuming that the key contains a valid numeric value.
func Float64 ¶
Float64 returns the float64 value of a given key path or 0 if the path does not exist or if the value is not a valid float64.
func Float64Map ¶
Float64Map returns the map[string]float64 value of a given key path or an empty map[string]float64 if the path does not exist or if the value is not a valid float64 map.
func Float64s ¶
Float64s returns the []float64 slice value of a given key path or an empty []float64 slice if the path does not exist or if the value is not a valid float64 slice.
func Int ¶
Int returns the int value of a given key path or 0 if the path does not exist or if the value is not a valid int.
func Int64 ¶
Int64 returns the int64 value of a given key path or 0 if the path does not exist or if the value is not a valid int64.
func Int64Map ¶
Int64Map returns the map[string]int64 value of a given key path or an empty map[string]int64 if the path does not exist or if the value is not a valid int64 map.
func Int64s ¶
Int64s returns the []int64 slice value of a given key path or an empty []int64 slice if the path does not exist or if the value is not a valid int slice.
func IntMap ¶
IntMap returns the map[string]int value of a given key path or an empty map[string]int if the path does not exist or if the value is not a valid int map.
func Ints ¶
Ints returns the []int slice value of a given key path or an empty []int slice if the path does not exist or if the value is not a valid int slice.
func String ¶
String returns the string value of a given key path or "" if the path does not exist or if the value is not a valid string.
func StringMap ¶
StringMap returns the map[string]string value of a given key path or an empty map[string]string if the path does not exist or if the value is not a valid string map.
func Strings ¶
Strings returns the []string slice value of a given key path or an empty []string slice if the path does not exist or if the value is not a valid string slice.
func Time ¶
Time attempts to parse the value of a given key path and return time.Time representation. If the value is numeric, it is treated as a UNIX timestamp and if it's string, a parse is attempted with the given layout.
func Unmarshal ¶
func Unmarshal(o interface{}) error
Unmarshal unmarshals the given struct using the mapstructure lib. The whole map is unmarshalled.
func UnmarshalWithPath ¶
UnmarshalWithPath unmarshals a given key path into the given struct using the mapstructure lib.