Prevent shadowning of keys when a nested key's value is nil.

This commit is contained in:
Laszlo Kiss 2016-01-23 22:17:01 -07:00
parent a212099cbe
commit 7d1565ac32

View file

@ -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 {