Documentation
¶
Overview ¶
Package config provides configuration management things.
Index ¶
- func DefaultSearchPaths() []string
- type Config
- type Viper
- func (v *Viper) All() map[string]interface{}
- func (v *Viper) AllKeys() []string
- func (v *Viper) Backend() interface{}
- func (v *Viper) Get(key string) interface{}
- func (v *Viper) GetBool(key string) bool
- func (v *Viper) GetDuration(key string) time.Duration
- func (v *Viper) GetFloat(key string) float64
- func (v *Viper) GetInt(key string) int
- func (v *Viper) GetIntSlice(key string) []int
- func (v *Viper) GetString(key string) string
- func (v *Viper) GetStringMap(key string) map[string]interface{}
- func (v *Viper) GetStringMapString(key string) map[string]string
- func (v *Viper) GetStringMapStringSlice(key string) map[string][]string
- func (v *Viper) GetStringSlice(key string) []string
- func (v *Viper) GetTime(key string) time.Time
- func (v *Viper) InConfig(key string) bool
- func (v *Viper) IsSet(key string) bool
- func (v *Viper) Name() string
- func (v *Viper) Set(key string, value interface{})
- func (v *Viper) SetDefault(key string, value interface{})
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultSearchPaths ¶
func DefaultSearchPaths() []string
DefaultSearchPaths returns default search directory paths for using in New.
Default paths slice include:
- $HOME;
- directory where executable is located;
- current working directory.
Types ¶
type Config ¶
type Config interface { // Name returns config name Name() string // Backend returns backend configuration engine Backend() interface{} // Get can retrieve any value given the key to use. Get(key string) interface{} // GetString returns the value associated with the key as a string. GetString(key string) string // GetBool returns the value associated with the key as a bool. GetBool(key string) bool // GetInt returns the value associated with the key as an integer. GetInt(key string) int // GetFloat returns the value associated with the key as a float64. GetFloat(key string) float64 // GetTime returns the value associated with the key as time. GetTime(key string) time.Time // GetDuration returns the value associated with the key as a duration. GetDuration(key string) time.Duration // GetIntSlice returns the value associated with the key as a slice of int values. GetIntSlice(key string) []int // GetStringSlice returns the value associated with the key as a slice of strings. GetStringSlice(key string) []string // GetStringMap returns the value associated with the key as a map of interfaces. GetStringMap(key string) map[string]interface{} // GetStringMapString returns the value associated with the key as a map of strings. GetStringMapString(key string) map[string]string // GetStringMapStringSlice returns the value associated with the key as a map to a slice of strings. GetStringMapStringSlice(key string) map[string][]string // IsSet checks to see if the key has been set in any of the data locations. IsSet(key string) bool // InConfig checks to see if the given key (or an alias) is in the config file. InConfig(key string) bool // SetDefault sets the default value for this key. SetDefault(key string, value interface{}) // Set sets the value for the key in the override register. Set(key string, value interface{}) // All returns all values. All() map[string]interface{} // AllKeys returns all keys. AllKeys() []string }
Config is the configuration interface.
func New ¶
New creates a new configuration instance using default parameters.
Returned configuration uses files and environment variables for getting config data.
func NewTesting ¶
NewTesting creates a new configuration instance using default parameters suitable for using in tests.
This configuration supports only direct and ENV settings.
type Viper ¶
type Viper struct {
// contains filtered or unexported fields
}
Viper is the Viper configuration backend.
func (*Viper) Backend ¶
func (v *Viper) Backend() interface{}
Backend returns backend configuration engine.
func (*Viper) GetDuration ¶
GetDuration returns the value associated with the key as a duration.
func (*Viper) GetIntSlice ¶
GetIntSlice returns the value associated with the key as a slice of int values.
func (*Viper) GetStringMap ¶
GetStringMap returns the value associated with the key as a map of interfaces.
func (*Viper) GetStringMapString ¶
GetStringMapString returns the value associated with the key as a map of strings.
func (*Viper) GetStringMapStringSlice ¶
GetStringMapStringSlice returns the value associated with the key as a map to a slice of strings.
func (*Viper) GetStringSlice ¶
GetStringSlice returns the value associated with the key as a slice of strings.
func (*Viper) InConfig ¶
InConfig checks to see if the given key (or an alias) is in the config file.
func (*Viper) SetDefault ¶
SetDefault sets the default value for this key.