diff --git a/viper.go b/viper.go index 7a49a0a..0f0a6d4 100644 --- a/viper.go +++ b/viper.go @@ -305,6 +305,10 @@ func (v *Viper) getEnv(key string) string { if v.envKeyReplacer != nil { key = v.envKeyReplacer.Replace(key) } + + // Replace dots with underscores, since that is the sensible mapping + // for environment variables. The -1 means replace all insstances of "." with "_" + key = strings.Replace(key, ".", "_", -1) return os.Getenv(key) }