mirror of
https://github.com/spf13/viper
synced 2024-12-22 11:37:02 +00:00
preserve default value if not set in config file
This commit is contained in:
parent
12990ac1c8
commit
31f218ede6
1 changed files with 3 additions and 1 deletions
4
viper.go
4
viper.go
|
@ -681,7 +681,9 @@ func (v *Viper) registerAlias(alias string, key string) {
|
||||||
source := v.find(path[0])
|
source := v.find(path[0])
|
||||||
if source != nil && reflect.TypeOf(source).Kind() == reflect.Map {
|
if source != nil && reflect.TypeOf(source).Kind() == reflect.Map {
|
||||||
val := v.searchMap(cast.ToStringMap(source), path[1:])
|
val := v.searchMap(cast.ToStringMap(source), path[1:])
|
||||||
v.config[key] = val
|
if val != nil {
|
||||||
|
v.config[key] = val
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
v.aliases[alias] = key
|
v.aliases[alias] = key
|
||||||
|
|
Loading…
Reference in a new issue