mirror of
https://github.com/spf13/viper
synced 2025-05-07 12:47:18 +00:00
mergeMaps support update diff type values
This commit is contained in:
parent
01e104428a
commit
2b0ff92949
1 changed files with 10 additions and 4 deletions
14
viper.go
14
viper.go
|
@ -1649,13 +1649,19 @@ func mergeMaps(
|
||||||
|
|
||||||
svType := reflect.TypeOf(sv)
|
svType := reflect.TypeOf(sv)
|
||||||
tvType := reflect.TypeOf(tv)
|
tvType := reflect.TypeOf(tv)
|
||||||
if svType != tvType {
|
// type different
|
||||||
v.logger.Errorf("svType != tvType; key=%s, st=%v, tt=%v, sv=%v, tv=%v", sk, svType, tvType, sv, tv)
|
diffType := svType != tvType
|
||||||
|
v.logger.Debugf("processing key=%s, st=%v, tt=%v, sv=%v, tv=%v, diffType=%v", sk, svType, tvType, sv, tv, diffType)
|
||||||
|
// just update when type different
|
||||||
|
if diffType {
|
||||||
|
v.logger.Debugf("setting diffType value")
|
||||||
|
tgt[tk] = sv
|
||||||
|
if itgt != nil {
|
||||||
|
itgt[tk] = sv
|
||||||
|
}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
v.logger.Debugf("processing key=%s, st=%v, tt=%v, sv=%v, tv=%v", sk, svType, tvType, sv, tv)
|
|
||||||
|
|
||||||
switch ttv := tv.(type) {
|
switch ttv := tv.(type) {
|
||||||
case map[interface{}]interface{}:
|
case map[interface{}]interface{}:
|
||||||
v.logger.Debugf("merging maps (must convert)")
|
v.logger.Debugf("merging maps (must convert)")
|
||||||
|
|
Loading…
Add table
Reference in a new issue