From 31f218ede6ef819285cd2ef7a18bd99f09efe43d Mon Sep 17 00:00:00 2001 From: Steeve Chailloux Date: Sat, 4 Jul 2015 02:28:58 -0500 Subject: [PATCH] preserve default value if not set in config file --- viper.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/viper.go b/viper.go index 172e324..ae56c0e 100644 --- a/viper.go +++ b/viper.go @@ -681,7 +681,9 @@ func (v *Viper) registerAlias(alias string, key string) { source := v.find(path[0]) if source != nil && reflect.TypeOf(source).Kind() == reflect.Map { val := v.searchMap(cast.ToStringMap(source), path[1:]) - v.config[key] = val + if val != nil { + v.config[key] = val + } } } v.aliases[alias] = key