Documentation ¶
Index ¶
- func GetBool(s string) bool
- func GetDuration(s string) time.Duration
- func GetInt(s string) int
- func GetString(s string, confmap ...map[string]string) string
- func GetStringMapString(s string, confmap ...map[string]string) map[string]string
- func GetStringSlice(s string, confmap ...map[string]string) []string
- func GetViper() *viper.Viper
- func Set(s string, i interface{})
- func SetDefault(s string, i interface{})
- type Config
- func (c *Config) ExpandString(input string, confmap map[string]string) (value string)
- func (c *Config) GetBool(s string) bool
- func (c *Config) GetDuration(s string) time.Duration
- func (c *Config) GetInt(s string) int
- func (c *Config) GetString(s string, confmap ...map[string]string) string
- func (c *Config) GetStringMapString(s string, confmap ...map[string]string) (m map[string]string)
- func (c *Config) GetStringSlice(s string, confmap ...map[string]string) (slice []string)
- func (c *Config) GetViper() *viper.Viper
- func (c *Config) Set(s string, i interface{})
- func (c *Config) SetDefault(s string, i interface{})
- func (c *Config) SetViper(v *viper.Viper)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetDuration ¶ added in v1.10.0
func GetString ¶
Returns the configuration item as a string with ExpandString() applied, passing the first "confmap" if given
func GetStringMapString ¶
func SetDefault ¶ added in v1.10.0
func SetDefault(s string, i interface{})
Types ¶
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
The Config type acts as a container for local/extended viper instances
func (*Config) ExpandString ¶
Return a string that has all contents of the form ${var} or $var expanded according to the following rules:
url - read the contents of the url, which can be a local file, as below: ${file://path/to/file} - read the entire contents of the file, trim whitespace ${https://host/path} - fetch the remote contents, trim whitespace. "http:" also supported. ${env:VARNAME} - replace with the contents of the environment varaible VARNAME, trim whitespace ${path.to.config} - and var containing a '.' will be looked up in global viper config space - this is NOT recursive ${name} - replace with the contents of confmap["name"] - trim whitespace
While the form $var is also supported but may be ambiguous and is not recommended.
If confmap is not given then environment variables are used directly.
Any errors result in an empty string being returned.
func (*Config) GetString ¶
Returns the configuration item as a string with ExpandString() applied, passing the first "confmap" if given
func (*Config) GetStringMapString ¶
func (*Config) GetStringSlice ¶
func (*Config) SetDefault ¶ added in v1.10.0
Click to show internal directories.
Click to hide internal directories.