Documentation ¶
Overview ¶
Package config provides a wrapper around koanf.
Index ¶
- 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 MergeOptionsWithPath[O any](opts *O, paths ...string) (*O, error)
- func NewOptionsWithPath[O any](paths ...string) (opts *O, err error)
- func Set(provider Provider)
- func SetEntries(v []Config)
- 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
- type Provider
Constants ¶
This section is empty.
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 MergeOptionsWithPath ¶
func NewOptionsWithPath ¶
NewOptionsWithPath unmarshal options based a given multi key paths.
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.
Types ¶
type Provider ¶
type Provider interface { Load([]Config) // UnmarshalWithPath unmarshals a given key path into the given struct using the mapstructure lib. UnmarshalWithPath(path string, o interface{}) error // Unmarshal unmarshals the given struct using the mapstructure lib. The whole map is unmarshalled. Unmarshal(o interface{}) error // Exists returns true if the given key path exists in the conf map. Exists(path string) bool // 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. Int64(path string) int64 // 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. Int64s(path string) []int64 // 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. Int64Map(path string) map[string]int64 // 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. Int(path string) int // 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. Ints(path string) []int // 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. IntMap(path string) map[string]int // 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. Float64(path string) float64 // 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. Float64s(path string) []float64 // 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. Float64Map(path string) map[string]float64 // Duration returns the time.Duration value of a given key path assuming // that the key contains a valid numeric value. Duration(path string) time.Duration // 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. Time(path, layout string) time.Time // 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. String(path string) string // 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. Strings(path string) []string // 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. StringMap(path string) map[string]string // 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. Bytes(path string) []byte // 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. Bool(path string) bool // 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. Bools(path string) []bool // 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. BoolMap(path string) map[string]bool // All returns all configs All() map[string]interface{} // Get returns interface{} value Get(path string) interface{} }