Documentation ¶
Overview ¶
Package viper provides convenience functions over the official spf13/viper library. In particular, it satisfies the need of providing a custom pre-configured global viper instance.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Default = viper.NewWithOptions(viper.KeyDelimiter("::"))
Default is the default, pre-configured instance of viper.
Functions ¶
func AddConfigPath ¶
func AddConfigPath(in string)
AddConfigPath adds a path for Viper to search for the config file in. Can be called multiple times to define multiple search paths.
func BindPFlag ¶
BindPFlag binds a specific key to a pflag (as used by cobra). Example (where serverCmd is a Cobra instance):
serverCmd.Flags().Int("port", 1138, "Port to run Application server on") Viper.BindPFlag("port", serverCmd.Flags().Lookup("port"))
func ReadInConfig ¶
func ReadInConfig() error
ReadInConfig will discover and load the configuration file from disk and key/value stores, searching in one of the defined paths.
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 SetConfigName ¶
func SetConfigName(in string)
SetConfigName sets name for the config file. Does not include extension.
func Unmarshal ¶
func Unmarshal(rawVal interface{}, opts ...viper.DecoderConfigOption) error
Unmarshal unmarshals the config into a Struct. Make sure that the tags on the fields of the structure are properly set.
Types ¶
This section is empty.