From 7d1565ac322e613b96246e59b55a9f236ff031a9 Mon Sep 17 00:00:00 2001 From: Laszlo Kiss Date: Sat, 23 Jan 2016 22:17:01 -0700 Subject: [PATCH] Prevent shadowning of keys when a nested key's value is nil. --- viper.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/viper.go b/viper.go index 00049ec..0c5310c 100644 --- a/viper.go +++ b/viper.go @@ -757,8 +757,10 @@ func (v *Viper) find(key string) interface{} { if source != nil { if reflect.TypeOf(source).Kind() == reflect.Map { val := v.searchMap(cast.ToStringMap(source), path[1:]) - jww.TRACE.Println(key, "found in nested config:", val) - return val + if val != nil { + jww.TRACE.Println(key, "found in nested config:", val) + return val + } } } }