Documentation ¶
Index ¶
- Variables
- func AddConfigPath(in string)
- func AllKeys() []string
- func AllSettings() map[string]interface{}
- func AutomaticEnv()
- func BindEnv(input ...string) (err error)
- func BindPFlag(key string, flag *pflag.Flag) (err error)
- func ConfigFileUsed() string
- func Debug()
- func Get(key string) interface{}
- func GetBool(key string) bool
- func GetFloat64(key string) float64
- func GetInt(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 InConfig(key string) bool
- func IsSet(key string) bool
- func Marshal(rawVal interface{}) error
- func MarshalKey(key string, rawVal interface{}) error
- func MarshallReader(in io.Reader)
- func ReadInConfig() error
- func RegisterAlias(alias string, key string)
- func Reset()
- func Set(key string, value interface{})
- func SetConfigFile(in string)
- func SetConfigName(in string)
- func SetConfigType(in string)
- func SetDefault(key string, value interface{})
- type UnsupportedConfigError
Constants ¶
This section is empty.
Variables ¶
var SupportedExts []string = []string{"json", "toml", "yaml", "yml"}
extensions Supported
Functions ¶
func AddConfigPath ¶
func AddConfigPath(in string)
func AllSettings ¶
func AllSettings() map[string]interface{}
func AutomaticEnv ¶
func AutomaticEnv()
Have viper check ENV variables for all keys set in config, default & flags
func BindEnv ¶
Binds a viper key to a ENV variable ENV variables are case sensitive If only a key is provided, it will use the env key matching the key, uppercased.
func BindPFlag ¶
Bind a specific key to a flag (as used by cobra)
serverCmd.Flags().Int("port", 1138, "Port to run Application server on") viper.BindPFlag("port", serverCmd.Flags().Lookup("port"))
func ConfigFileUsed ¶
func ConfigFileUsed() string
func Get ¶
func Get(key string) interface{}
Get returns an interface.. Must be typecast or used by something that will typecast
func GetFloat64 ¶
func GetStringMap ¶
func GetStringMapString ¶
func GetStringSlice ¶
func MarshalKey ¶
Takes a single key and marshals it into a Struct
func MarshallReader ¶
func ReadInConfig ¶
func ReadInConfig() error
Viper will discover and load the configuration file from disk searching in one of the defined paths.
func RegisterAlias ¶
Aliases provide another accessor for the same key. This enables one to change a name without breaking the application
func Set ¶
func Set(key string, value interface{})
The user provided value (via flag) Will be used instead of values obtained via config file, ENV or default
func SetConfigFile ¶
func SetConfigFile(in string)
Explicitly define the path, name and extension of the config file Viper will use this and not check any of the config paths
func SetConfigName ¶
func SetConfigName(in string)
Name for the config file. Does not include extension.
func SetConfigType ¶
func SetConfigType(in string)
func SetDefault ¶
func SetDefault(key string, value interface{})
Set the default value for this key. Default only used when no value is provided by the user via flag, config or ENV.
Types ¶
type UnsupportedConfigError ¶
type UnsupportedConfigError string
func (UnsupportedConfigError) Error ¶
func (str UnsupportedConfigError) Error() string