@@ -205,7 +205,6 @@ type Viper struct {
205205 envKeyReplacer StringReplacer
206206 allowEmptyEnv bool
207207
208- parents []string
209208 config map [string ]interface {}
210209 override map [string ]interface {}
211210 defaults map [string ]interface {}
@@ -232,7 +231,6 @@ func New() *Viper {
232231 v .configPermissions = os .FileMode (0o644 )
233232 v .fs = afero .NewOsFs ()
234233 v .config = make (map [string ]interface {})
235- v .parents = []string {}
236234 v .override = make (map [string ]interface {})
237235 v .defaults = make (map [string ]interface {})
238236 v .kvstore = make (map [string ]interface {})
@@ -956,9 +954,8 @@ func (v *Viper) Sub(key string) *Viper {
956954 }
957955
958956 if reflect .TypeOf (data ).Kind () == reflect .Map {
959- subv .parents = append (v .parents , strings .ToLower (key ))
960957 subv .automaticEnvApplied = v .automaticEnvApplied
961- subv .envPrefix = v .envPrefix
958+ subv .envPrefix = v .mergeWithEnvPrefix ( key )
962959 subv .envKeyReplacer = v .envKeyReplacer
963960 subv .config = cast .ToStringMap (data )
964961 return subv
@@ -1307,10 +1304,9 @@ func (v *Viper) find(lcaseKey string, flagDefault bool) interface{} {
13071304
13081305 // Env override next
13091306 if v .automaticEnvApplied {
1310- envKey := strings .Join (append (v .parents , lcaseKey ), "." )
13111307 // even if it hasn't been registered, if automaticEnv is used,
13121308 // check any Get request
1313- if val , ok := v .getEnv (v .mergeWithEnvPrefix (envKey )); ok {
1309+ if val , ok := v .getEnv (v .mergeWithEnvPrefix (lcaseKey )); ok {
13141310 return val
13151311 }
13161312 if nested && v .isPathShadowedInAutoEnv (path ) != "" {
0 commit comments