Documentation ¶
Index ¶
- func AddConfigItems(configKeys []string)
- func AddConfigItemsWithPFlags(configKeys []string) error
- func AllSettings() map[string]interface{}
- func ApplyWith(key string, f func(interface{}))
- func DryRun(reason string, args ...interface{}) bool
- func FromStringOrFunc(val interface{}) (string, error)
- func Get(key string) interface{}
- func GetBool(key string) bool
- func GetDuration(key string) time.Duration
- 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 Init(initConfig Config)
- func IsSet(key string) bool
- func MissingValueIsEmpty(val interface{}, err error) interface{}
- func Must(val interface{}, err error) interface{}
- type Config
- type MissingValue
- type UnsupportedValue
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddConfigItems ¶
func AddConfigItems(configKeys []string)
AddConfigItems passes the configItems through to settings.AddConfigItems()
func AddConfigItemsWithPFlags ¶ added in v0.2.6
AddConfigItemsWithFlags passes the configItems through to settings.AddConfigItemsWithFlags()
func AllSettings ¶ added in v0.2.3
func AllSettings() map[string]interface{}
AllSettings forwards to viper.AllSettings
func ApplyWith ¶
func ApplyWith(key string, f func(interface{}))
ApplyWith gets a setting from viper, and passes it to a closure
func FromStringOrFunc ¶ added in v0.2.0
FromStringOrFunc will return a different value depending on the provided val: - If it's a string, provide the given val - If it's a func(), provide the val returned by the func
func GetDuration ¶ added in v0.2.3
GetDuration forwards to viper.GetDuration
func GetFloat64 ¶ added in v0.2.3
GetFloat64 forwards to viper.GetFloat64
func GetStringMap ¶ added in v0.2.3
GetStringMap forwards to viper.GetStringMap
func GetStringMapString ¶ added in v0.2.3
GetStringMapString forwards to viper.GetStringMapString
func GetStringSlice ¶ added in v0.2.3
GetStringSlice forwards to viper.GetStringSlice
func MissingValueIsEmpty ¶ added in v0.3.0
func MissingValueIsEmpty(val interface{}, err error) interface{}
MissingValueIsEmpty panics if "err" != nil or is a "MissingValue" type, otherwise it returns the "val"
Types ¶
type Config ¶
type Config struct { File string Dir string OnlyUseDir bool EnvPrefix string Debug bool FromConfig bool Name interface{} Environment interface{} Release interface{} LoggingFormat string LoggingSentryDsn string // contains filtered or unexported fields }
Config provides basic fields for configuring the "settings" and "logging" packages.
"File" is the name of a file that Viper will read for configuration. By default, it searches for the file in the user's `$HOME` dir as well as the current workig dir -- but see "OnlyUseDir" below. If the file-name is empty, settings won't be loaded from a file (only env-vars).
"Dir" is an optional additional additional dir to search for a config file.
"OnlyUseDir" when false will additionally search "$HOME" and current working dir for the config file. When true, will only search in the above "Dir" directory. If "Dir" is not given, then the config file won't be loaded.
"EnvPrefix" is a required prefix-string that Viper uses to filter Env-vars for settings.
"Debug" enables debug logging if set to "true":
"FromConfig" enables the following settings (Name ... LoggingSentryDsn) to be configured via Viper. This means it will use the above Config file and appropriate Env-vars
"Name" is the App name, used in log messages. This can be a string, or a func ref that will return a string.
"Environment" is the App's environment it was run in -- e.g. "staging" or "prod" This can be a string, or a func ref that will return a string.
"Release" is the App's release / version string This can be a string, or a func ref that will return a string.
"LoggingFormat" sets the log-out format for log messages
"LoggingSentryDsn" is the connection string (DSN) used to send errors to Sentry.io
type MissingValue ¶ added in v0.3.0
type MissingValue struct {
Val interface{}
}
func (*MissingValue) Error ¶ added in v0.3.0
func (s *MissingValue) Error() string
type UnsupportedValue ¶ added in v0.3.0
type UnsupportedValue struct {
Val interface{}
}
func (*UnsupportedValue) Error ¶ added in v0.3.0
func (s *UnsupportedValue) Error() string