package
1.13.7
Repository: https://github.com/starudream/go-lib.git
Documentation: pkg.go.dev

# Packages

No description provided by the author

# Functions

AddConfigPath adds a path for Viper to search for the config file in.
AllKeys returns all keys holding a value, regardless of where they are set.
AllowEmptyEnv tells Viper to consider set, but empty environment variables as valid values instead of falling back.
AllSettings merges all settings and returns them as a map[string]interface{}.
AutomaticEnv makes Viper check if environment variables match any of the existing keys (config, default or flags).
BindEnv binds a Viper key to a ENV variable.
BindFlagValue binds a specific key to a FlagValue.
BindFlagValues binds a full FlagValue set to the configuration, using each flag's long name as the config key.
BindPFlag binds a specific key to a pflag (as used by cobra).
BindPFlags binds a full flag set to the configuration, using each flag's long name as the config key.
ConfigFileUsed returns the file used to populate the config registry.
Debug prints all configuration registries for debugging purposes.
No description provided by the author
DecodeHook returns a DecoderConfigOption which overrides the default DecoderConfig.DecodeHook value, the default is: mapstructure.ComposeDecodeHookFunc( mapstructure.StringToTimeDurationHookFunc(), mapstructure.StringToSliceHookFunc(","), ).
EnvKeyReplacer sets a replacer used for mapping environment variables to internal keys.
Get can retrieve any value given the key to use.
GetBool returns the value associated with the key as a boolean.
GetDuration returns the value associated with the key as a duration.
GetFloat64 returns the value associated with the key as a float64.
GetInt returns the value associated with the key as an integer.
GetInt32 returns the value associated with the key as an integer.
GetInt64 returns the value associated with the key as an integer.
GetIntSlice returns the value associated with the key as a slice of int values.
GetSizeInBytes returns the size of the value associated with the given key in bytes.
GetString returns the value associated with the key as a string.
GetStringMap returns the value associated with the key as a map of interfaces.
GetStringMapString returns the value associated with the key as a map of strings.
GetStringMapStringSlice returns the value associated with the key as a map to a slice of strings.
GetStringSlice returns the value associated with the key as a slice of strings.
GetTime returns the value associated with the key as time.
GetUint returns the value associated with the key as an unsigned integer.
GetUint16 returns the value associated with the key as an unsigned integer.
GetUint32 returns the value associated with the key as an unsigned integer.
GetUint64 returns the value associated with the key as an unsigned integer.
GetViper gets the global Viper instance.
InConfig checks to see if the given key (or an alias) is in the config file.
IsSet checks to see if the key has been set in any of the data locations.
KeyDelimiter sets the delimiter used for determining key parts.
MergeConfig merges a new configuration with an existing config.
MergeConfigMap merges the configuration from the map given with an existing config.
MergeInConfig merges a new configuration with an existing config.
MustBindEnv wraps BindEnv in a panic.
New returns an initialized Viper instance.
NewWithOptions creates a new Viper instance.
OnConfigChange sets the event handler that is called when a config file changes.
ReadConfig will read a configuration file, setting existing keys to nil if the key does not exist in the file.
ReadInConfig will discover and load the configuration file from disk and key/value stores, searching in one of the defined paths.
RegisterAlias creates an alias that provides another accessor for the same key.
Reset is intended for testing, will reset all to default settings.
SafeWriteConfig writes current configuration to file only if the file does not exist.
SafeWriteConfigAs writes current configuration to a given filename if it does not exist.
Set sets the value for the key in the override register.
SetConfigFile explicitly defines the path, name and extension of the config file.
SetConfigName sets name for the config file.
SetConfigPermissions sets the permissions for the config file.
SetConfigType sets the type of the configuration returned by the remote source, e.g.
SetDefault sets the default value for this key.
SetEnvKeyReplacer sets the strings.Replacer on the viper object Useful for mapping an environmental variable to a key that does not match it.
SetEnvPrefix defines a prefix that ENVIRONMENT variables will use.
SetFs sets the filesystem to use to read configuration.
SetTypeByDefaultValue enables or disables the inference of a key value's type when the Get function is used based upon a key's default value as opposed to the value returned based on the normal fetch logic.
Sub returns new Viper instance representing a sub tree of this instance.
Unmarshal unmarshals the config into a Struct.
UnmarshalExact unmarshals the config into a Struct, erroring if a field is nonexistent in the destination struct.
UnmarshalKey takes a single key and unmarshals it into a Struct.
WatchConfig starts watching a config file for changes.
WithLogger sets a custom logger.
WriteConfig writes the current configuration to a file.
WriteConfigAs writes current configuration to a given filename.

# Variables

SupportedExts are universally supported extensions.

# Structs

ConfigFileNotFoundError denotes failing to find configuration file.
ConfigMarshalError happens when failing to marshal the configuration.
ConfigParseError denotes failing to parse configuration file.
Viper is a prioritized configuration registry.

# Interfaces

FlagValue is an interface that users can implement to bind different flags to viper.
FlagValueSet is an interface that users can implement to bind a set of flags to viper.
Logger is a unified interface for various logging use cases and practices, including: - leveled logging - structured logging.
Option configures Viper using the functional options paradigm popularized by Rob Pike and Dave Cheney.
StringReplacer applies a set of replacements to a string.

# Type aliases

ConfigFileAlreadyExistsError denotes failure to write new configuration file.
A DecoderConfigOption can be passed to viper.Unmarshal to configure mapstructure.DecoderConfig options.
UnsupportedConfigError denotes encountering an unsupported configuration filetype.