@@ -205,7 +205,6 @@ type Viper struct {
205
205
envKeyReplacer StringReplacer
206
206
allowEmptyEnv bool
207
207
208
- parents []string
209
208
config map [string ]interface {}
210
209
override map [string ]interface {}
211
210
defaults map [string ]interface {}
@@ -232,7 +231,6 @@ func New() *Viper {
232
231
v .configPermissions = os .FileMode (0o644 )
233
232
v .fs = afero .NewOsFs ()
234
233
v .config = make (map [string ]interface {})
235
- v .parents = []string {}
236
234
v .override = make (map [string ]interface {})
237
235
v .defaults = make (map [string ]interface {})
238
236
v .kvstore = make (map [string ]interface {})
@@ -956,9 +954,8 @@ func (v *Viper) Sub(key string) *Viper {
956
954
}
957
955
958
956
if reflect .TypeOf (data ).Kind () == reflect .Map {
959
- subv .parents = append (v .parents , strings .ToLower (key ))
960
957
subv .automaticEnvApplied = v .automaticEnvApplied
961
- subv .envPrefix = v .envPrefix
958
+ subv .envPrefix = v .mergeWithEnvPrefix ( key )
962
959
subv .envKeyReplacer = v .envKeyReplacer
963
960
subv .config = cast .ToStringMap (data )
964
961
return subv
@@ -1307,10 +1304,9 @@ func (v *Viper) find(lcaseKey string, flagDefault bool) interface{} {
1307
1304
1308
1305
// Env override next
1309
1306
if v .automaticEnvApplied {
1310
- envKey := strings .Join (append (v .parents , lcaseKey ), "." )
1311
1307
// even if it hasn't been registered, if automaticEnv is used,
1312
1308
// check any Get request
1313
- if val , ok := v .getEnv (v .mergeWithEnvPrefix (envKey )); ok {
1309
+ if val , ok := v .getEnv (v .mergeWithEnvPrefix (lcaseKey )); ok {
1314
1310
return val
1315
1311
}
1316
1312
if nested && v .isPathShadowedInAutoEnv (path ) != "" {
0 commit comments