mirror of
https://github.com/spf13/viper
synced 2024-12-23 12:07:02 +00:00
Prevent shadowning of keys when a nested key's value is nil.
This commit is contained in:
parent
a212099cbe
commit
7d1565ac32
1 changed files with 4 additions and 2 deletions
2
viper.go
2
viper.go
|
@ -757,11 +757,13 @@ func (v *Viper) find(key string) interface{} {
|
||||||
if source != nil {
|
if source != nil {
|
||||||
if reflect.TypeOf(source).Kind() == reflect.Map {
|
if reflect.TypeOf(source).Kind() == reflect.Map {
|
||||||
val := v.searchMap(cast.ToStringMap(source), path[1:])
|
val := v.searchMap(cast.ToStringMap(source), path[1:])
|
||||||
|
if val != nil {
|
||||||
jww.TRACE.Println(key, "found in nested config:", val)
|
jww.TRACE.Println(key, "found in nested config:", val)
|
||||||
return val
|
return val
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
val, exists = v.kvstore[key]
|
val, exists = v.kvstore[key]
|
||||||
if exists {
|
if exists {
|
||||||
|
|
Loading…
Reference in a new issue