Documentation ¶
Index ¶
- func AllSettings() map[string]interface{}
- func Get(key string, defaultValue ...interface{}) interface{}
- func GetBool(key string, defaultValue ...bool) bool
- func GetDuration(key string, defaultValue ...time.Duration) time.Duration
- func GetFloat64(key string, defaultValue ...float64) float64
- func GetInt(key string, defaultValue ...int) int
- func GetInt64(key string, defaultValue ...int64) int64
- func GetString(key string, defaultValue ...string) string
- func GetStringMap(key string, defaultValue ...map[string]interface{}) map[string]interface{}
- func GetStringMapString(key string, defaultValue ...map[string]string) map[string]string
- func GetStringSlice(key string, defaultValue ...[]string) []string
- func GetTime(key string, defaultValue ...time.Time) time.Time
- func GetValue(key string, defaultValue ...interface{}) interface{}
- func Has(key string) bool
- func Load(configPath string, configName ...string)
- func LoadAll(configPath string) error
- func LoadEnv(prefix ...string)
- func MergeConfigMap(cfg map[string]interface{})
- func Set(key string, value interface{})
- func Unmarshal(rawVal interface{}) error
- func UnmarshalKey(key string, rawVal interface{}) error
- type Config
- func (c *Config) AllSettings() map[string]interface{}
- func (c *Config) Get(key string, defaultValue ...interface{}) interface{}
- func (c *Config) GetBool(key string, defaultValue ...bool) bool
- func (c *Config) GetDuration(key string, defaultValue ...time.Duration) time.Duration
- func (c *Config) GetFloat64(key string, defaultValue ...float64) float64
- func (c *Config) GetInt(key string, defaultValue ...int) int
- func (c *Config) GetInt64(key string, defaultValue ...int64) int64
- func (c *Config) GetString(key string, defaultValue ...string) string
- func (c *Config) GetStringMap(key string, defaultValue ...map[string]interface{}) map[string]interface{}
- func (c *Config) GetStringMapString(key string, defaultValue ...map[string]string) map[string]string
- func (c *Config) GetStringSlice(key string, defaultValue ...[]string) []string
- func (c *Config) GetTime(key string, defaultValue ...time.Time) time.Time
- func (c *Config) GetValue(key string, defaultValue ...interface{}) interface{}
- func (c *Config) Has(key string) bool
- func (c *Config) LoadEnv(prefix ...string)
- func (c *Config) MergeConfigMap(cfg map[string]interface{})
- func (c *Config) Set(key string, value interface{})
- func (c *Config) Sub(key string) *Config
- func (c *Config) Unmarshal(rawVal interface{}) error
- func (c *Config) UnmarshalKey(key string, rawVal interface{}) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AllSettings ¶
func AllSettings() map[string]interface{}
AllSettings gets all settings in config.
func Get ¶
func Get(key string, defaultValue ...interface{}) interface{}
Get is shorthand for GetValue.
func GetDuration ¶
GetDuration gets duration value of the key or fallback to the default value.
func GetFloat64 ¶
GetFloat64 gets float64 value of the key or fallback to the default value.
func GetStringMap ¶
GetStringMap gets map[string]interface{} value of the key or fallback to the default value.
func GetStringMapString ¶
GetStringMapString gets map[string]string value of the key or fallback to the default value.
func GetStringSlice ¶
GetStringSlice gets string slice value of the key or fallback to the default value.
func GetValue ¶
func GetValue(key string, defaultValue ...interface{}) interface{}
GetValue gets value of the key or fallback to the default value.
func Has ¶
Has checks to see if the key has been set in any of the data locations. Has is case-insensitive for a key.
func LoadEnv ¶
func LoadEnv(prefix ...string)
LoadEnv loads env from .env or command line Use prefix to avoid conflicts with other env variables Same config key in env will override that in config file
func MergeConfigMap ¶
func MergeConfigMap(cfg map[string]interface{})
MergeConfigMap merges the configuration from the map given with an existing config. Note that the map given may be modified.
func Set ¶
func Set(key string, value interface{})
Set sets the value for the key in the override register. Set is case-insensitive for a key. Will be used instead of values obtained via flags, config file, ENV, default, or key/value store.
func Unmarshal ¶
func Unmarshal(rawVal interface{}) error
Unmarshal unmarshals the config into a Struct. Make sure that the tags on the fields of the structure are properly set.
func UnmarshalKey ¶
UnmarshalKey takes a single key and unmarshals it into a Struct.
Types ¶
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
Config is based on spf13/viper and extends by supporting default value
func New ¶
New returns a new Config instance. If a specified filePath(with or without extension are both fine) is given, then read config from that file.
func Sub ¶
Sub returns a new Config instance representing a sub tree of this instance. Sub is case-insensitive for a key.