Documentation ¶
Index ¶
- Variables
- func GetBool(key string) bool
- func GetDuration(key string) time.Duration
- func GetFloat64(key string) float64
- func GetInt(key string) int
- func GetInt32(key string) int32
- func GetInt64(key string) int64
- func GetIntSlice(key string) []int
- func GetString(key string) string
- func GetStringMap(key string) map[string]interface{}
- func GetStringMapString(key string) map[string]string
- func GetStringSlice(key string) []string
- func GetTime(key string) time.Time
- func GetUint(key string) uint
- func GetUint32(key string) uint32
- func GetUint64(key string) uint64
- func SetConfig(config *Config)
- func WatchVariable(key string, cb WatcherCallback) error
- type Config
- type Value
- type WatcherCallback
Constants ¶
This section is empty.
Variables ¶
var ( ErrEmptyKey = errors.New("key is empty") ErrNilVariable = errors.New("variable is nil") )
Config errors.
Functions ¶
func GetDuration ¶
GetDuration returns the value associated with the key as a duration.
func GetFloat64 ¶
GetFloat64 returns the value associated with the key as a float64.
func GetIntSlice ¶
GetIntSlice returns the value associated with the key as a slice of int values.
func GetStringMap ¶
GetStringMap returns the value associated with the key as a map of interfaces.
func GetStringMapString ¶
GetStringMapString returns the value associated with the key as a map of strings.
func GetStringSlice ¶
GetStringSlice returns the value associated with the key as a slice of strings.
func SetConfig ¶ added in v0.24.0
func SetConfig(config *Config)
SetConfig sets global config instance.
func WatchVariable ¶
func WatchVariable(key string, cb WatcherCallback) error
WatchVariable allows to set a callback func on a specific variable change.
Types ¶
type Config ¶ added in v0.24.0
type Config struct {
// contains filtered or unexported fields
}
Config is viper wrapper.
func (*Config) Get ¶ added in v0.24.0
Get returns a config Value associated with the key in viper config.
func (*Config) SetConfigFile ¶ added in v0.24.0
SetConfigFile sets config file.
func (*Config) SetDefaultConfigFile ¶ added in v0.24.0
SetDefaultConfigFile sets default config file.
func (*Config) WatchConfig ¶ added in v0.24.0
func (c *Config) WatchConfig()
WatchConfig starts config watching.
func (*Config) WatchVariable ¶ added in v0.24.0
func (c *Config) WatchVariable(key string, cb WatcherCallback) error
WatchVariable allows to set a callback func on a specific variable change in viper config.
type Value ¶
type Value interface { IsNil() bool String() string Bool() bool Int() int Int32() int32 Int64() int64 Uint() uint Uint32() uint32 Uint64() uint64 Float64() float64 Time() time.Time Duration() time.Duration IntSlice() []int StringSlice() []string StringMap() map[string]interface{} StringMapString() map[string]string }
Value describes a config value.
type WatcherCallback ¶
type WatcherCallback func(oldValue, newValue Value)
WatcherCallback is a callback function for a variable watcher.