Documentation ¶
Index ¶
- type ViperConf
- func (v *ViperConf) Alias(key string, alias string) *ViperConf
- func (v *ViperConf) AllKeys() []string
- func (v *ViperConf) AllSettings() map[string]interface{}
- func (v *ViperConf) ConfigFileUsed() string
- func (v *ViperConf) Default(key string, value interface{}) *ViperConf
- func (v *ViperConf) Get(key string) interface{}
- func (v *ViperConf) GetBool(key string) bool
- func (v *ViperConf) GetDuration(key string) time.Duration
- func (v *ViperConf) GetFloat64(key string) float64
- func (v *ViperConf) GetInt(key string) int
- func (v *ViperConf) GetInt64(key string) int64
- func (v *ViperConf) GetIntSlice(key string) []int
- func (v *ViperConf) GetString(key string) string
- func (v *ViperConf) GetStringMapInterface(key string) map[string]interface{}
- func (v *ViperConf) GetStringMapString(key string) map[string]string
- func (v *ViperConf) GetStringMapStringSlice(key string) map[string][]string
- func (v *ViperConf) GetStringSlice(key string) []string
- func (v *ViperConf) GetTime(key string) time.Time
- func (v *ViperConf) Init() (bool, error)
- func (v *ViperConf) IsDefined(key string) bool
- func (v *ViperConf) IsSet(key string) bool
- func (v *ViperConf) Save() error
- func (v *ViperConf) Set(key string, value interface{}) *ViperConf
- func (v *ViperConf) Size(key string) int64
- func (v *ViperConf) SubConf(key string) *ViperConf
- func (v *ViperConf) Unmarshal(outputStructPtr interface{}, key ...string) error
- func (v *ViperConf) WatchConfig()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ViperConf ¶
type ViperConf struct { // define config properties ConfigName string SpecificConfigFileFullPath string UseYAML bool UseAutomaticEnvVar bool AppName string UseConfigPathEtcAppName bool UseConfigPathHomeAppName bool CustomConfigPath string // contains filtered or unexported fields }
ConfigName or SpecificConfigFileFullPath = One of the field is required UseYAML = true uses YAML; false uses JSON UseAutomaticEnvVar = true will auto load environment variables that matches to key AppName = used by config path options, identifies the name of the app UseConfig... = indicates config file search pattern
func (*ViperConf) Alias ¶
Alias will create an alias for the related key, this allows the alias name and key name both refer to the same stored config data
func (*ViperConf) AllSettings ¶
AllSettings returns map of all settings in config file
func (*ViperConf) ConfigFileUsed ¶
ConfigFileUsed returns the current config file full path in use
func (*ViperConf) GetDuration ¶
GetDuration returns value by key
func (*ViperConf) GetFloat64 ¶
GetFloat64 returns value by key
func (*ViperConf) GetIntSlice ¶
GetIntSlice returns value by key
func (*ViperConf) GetStringMapInterface ¶
GetStringMapInterface returns value by key
func (*ViperConf) GetStringMapString ¶
GetStringMapString returns value by key
func (*ViperConf) GetStringMapStringSlice ¶
GetStringMapStringSlice returns value by key
func (*ViperConf) GetStringSlice ¶
GetStringSlice returns value by key
func (*ViperConf) Init ¶
Init will initialize config and readInConfig if config file does not exist, false is returned
func (*ViperConf) Unmarshal ¶
Unmarshal serializes config content into output struct, optionally serializes a portion of config identified by key into a struct
struct tag use `mapstructure:""` if struct tag refers to sub element of yaml, define struct to contain the sub elements
for example: parentkey: childkey: abc childkey_2: xyz type Child struct { ChildKey string `mapstructure:"childkey"` ChildKey2 string `mapstructure:"childkey_2"` } type Parent struct { ChildData Child `mapstructure:"parentkey"`}
func (*ViperConf) WatchConfig ¶
func (v *ViperConf) WatchConfig()
if config file does not exist, this call will panic