mirror of
https://github.com/spf13/viper
synced 2024-12-22 19:47:01 +00:00
Update docs
This commit is contained in:
parent
b655224c01
commit
ea890285a5
2 changed files with 6 additions and 3 deletions
|
@ -250,9 +250,10 @@ using `SetEnvPrefix`, you can tell Viper to use a prefix while reading from
|
||||||
the environment variables. Both `BindEnv` and `AutomaticEnv` will use this
|
the environment variables. Both `BindEnv` and `AutomaticEnv` will use this
|
||||||
prefix.
|
prefix.
|
||||||
|
|
||||||
`BindEnv` takes one or two parameters. The first parameter is the key name, the
|
`BindEnv` takes one or more parameters. The first parameter is the key name, the
|
||||||
second is the name of the environment variable. The name of the environment
|
rest are the name of the environment variables to bind to this key. If more than
|
||||||
variable is case sensitive. If the ENV variable name is not provided, then
|
one are provided, they will take precedence in the specified order. The name of
|
||||||
|
the environment variable is case sensitive. If the ENV variable name is not provided, then
|
||||||
Viper will automatically assume that the ENV variable matches the following format: prefix + "_" + the key name in ALL CAPS. When you explicitly provide the ENV variable name (the second parameter),
|
Viper will automatically assume that the ENV variable matches the following format: prefix + "_" + the key name in ALL CAPS. When you explicitly provide the ENV variable name (the second parameter),
|
||||||
it **does not** automatically add the prefix. For example if the second parameter is "id",
|
it **does not** automatically add the prefix. For example if the second parameter is "id",
|
||||||
Viper will look for the ENV variable "ID".
|
Viper will look for the ENV variable "ID".
|
||||||
|
|
2
viper.go
2
viper.go
|
@ -1025,6 +1025,8 @@ func (v *Viper) BindFlagValue(key string, flag FlagValue) error {
|
||||||
// BindEnv binds a Viper key to a ENV variable.
|
// BindEnv binds a Viper key to a ENV variable.
|
||||||
// ENV variables are case sensitive.
|
// ENV variables are case sensitive.
|
||||||
// If only a key is provided, it will use the env key matching the key, uppercased.
|
// If only a key is provided, it will use the env key matching the key, uppercased.
|
||||||
|
// If more arguments are provided, they will represent the env variable names that
|
||||||
|
// should bind to this key and will be taken in the specified order.
|
||||||
// EnvPrefix will be used when set when env name is not provided.
|
// EnvPrefix will be used when set when env name is not provided.
|
||||||
func BindEnv(input ...string) error { return v.BindEnv(input...) }
|
func BindEnv(input ...string) error { return v.BindEnv(input...) }
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue