mirror of
https://github.com/spf13/viper
synced 2025-05-11 06:37:27 +00:00
Add env prefix accessor method
This commit is contained in:
parent
4938331709
commit
96b2599ee2
1 changed files with 9 additions and 0 deletions
9
viper.go
9
viper.go
|
@ -428,6 +428,15 @@ func (v *Viper) SetEnvPrefix(in string) {
|
|||
}
|
||||
}
|
||||
|
||||
// EnvPrefix returns the ENV prefix set with SetEnvPrefix for the global
|
||||
// Viper instance.
|
||||
func EnvPrefix() string { return v.envPrefix }
|
||||
|
||||
// EnvPrefix returns the env prefix set with SetEnvPrefix.
|
||||
func (v *Viper) EnvPrefix() string {
|
||||
return v.envPrefix
|
||||
}
|
||||
|
||||
func (v *Viper) mergeWithEnvPrefix(in string) string {
|
||||
if v.envPrefix != "" {
|
||||
return strings.ToUpper(v.envPrefix + "_" + in)
|
||||
|
|
Loading…
Add table
Reference in a new issue