Documentation ¶
Index ¶
- Variables
- func Get(key string, configName ...string) (value interface{})
- func GetBool(key string, configName ...string) (value bool)
- func GetDuration(key string, configName ...string) (value time.Duration)
- func GetFloat64(key string, configName ...string) (value float64)
- func GetInt(key string, configName ...string) (value int)
- func GetInt64(key string, configName ...string) (value int64)
- func GetString(key string, configName ...string) (value string)
- func GetStringMapString(key string, configName ...string) (value map[string][]string)
- func GetStringSlice(key string, configName ...string) (value []string)
- func GetTime(key string, configName ...string) (value time.Time)
- func NewConfigFromFile(configName, configType, filePath string, options NewConfigOptions) (err error)
- func NewConfigFromString(configName, value string, options NewConfigOptions) (err error)
- func UnmarshalKey(key string, rawVal interface{}, configName ...string) (err error)
- type NewConfigOptions
Constants ¶
This section is empty.
Variables ¶
var (
// DefaultConfigName default config name for viper
DefaultConfigName = "default"
)
Functions ¶
func GetDuration ¶
GetDuration get configuration value from an instance type time.Duration
func GetFloat64 ¶
GetFloat64 get configuration value from an instance type float64
func GetStringMapString ¶
GetStringMapString get configuration value from an instance type map string of string
func GetStringSlice ¶
GetStringSlice get configuration value from an instance type slice of string
func NewConfigFromFile ¶
func NewConfigFromFile(configName, configType, filePath string, options NewConfigOptions) (err error)
NewConfigFromFile instantiate new configuration instance Config in this example is read-only, you can't set it on the fly so don't return any possible interface to do so
func NewConfigFromString ¶
func NewConfigFromString(configName, value string, options NewConfigOptions) (err error)
NewConfigFromString instantiate new configuration instance using string, useful for testing
func UnmarshalKey ¶
UnmarshalKey takes a single key and unmarshals it into a Struct.
Types ¶
type NewConfigOptions ¶
type NewConfigOptions struct { // DefaultName used for default config name that will be used DefaultName string // Defaults used for default value for each config Defaults map[string]interface{} IsWatch bool }
NewConfigOptions options for initializing new config instance