forked from mirror/viper
Fix merging a key into a nil target
When merging a key where the target value is nil, the type of the target and source do not match. What currently happens is an error is logged and the key is skipped. I have changed it so that it does the same thing as when the target key is missing: copy the source value to the target. Signed-off-by: Carolyn Van Slyck <me@carolynvanslyck.com>
This commit is contained in:
parent
36be6bf91f
commit
cdb5e5976f
2
viper.go
2
viper.go
|
@ -1826,7 +1826,7 @@ func mergeMaps(
|
|||
|
||||
svType := reflect.TypeOf(sv)
|
||||
tvType := reflect.TypeOf(tv)
|
||||
if svType != tvType {
|
||||
if tvType != nil && svType != tvType { // Allow for the target to be nil
|
||||
jww.ERROR.Printf(
|
||||
"svType != tvType; key=%s, st=%v, tt=%v, sv=%v, tv=%v",
|
||||
sk, svType, tvType, sv, tv)
|
||||
|
|
|
@ -1695,6 +1695,7 @@ hello:
|
|||
pop: 37890
|
||||
largenum: 765432101234567
|
||||
num2pow63: 9223372036854775808
|
||||
universe: null
|
||||
world:
|
||||
- us
|
||||
- uk
|
||||
|
|
Loading…
Reference in New Issue