mirror of
https://github.com/spf13/viper
synced 2025-05-05 19:57:18 +00:00
Merge pull request #2 from xurwxj/f_support_different_type_set
mergeMaps support update diff type values
This commit is contained in:
commit
0c7eef9240
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)
|
||||
tvType := reflect.TypeOf(tv)
|
||||
if svType != tvType {
|
||||
v.logger.Errorf("svType != tvType; key=%s, st=%v, tt=%v, sv=%v, tv=%v", sk, svType, tvType, sv, tv)
|
||||
// type different
|
||||
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
|
||||
}
|
||||
|
||||
v.logger.Debugf("processing key=%s, st=%v, tt=%v, sv=%v, tv=%v", sk, svType, tvType, sv, tv)
|
||||
|
||||
switch ttv := tv.(type) {
|
||||
case map[interface{}]interface{}:
|
||||
v.logger.Debugf("merging maps (must convert)")
|
||||
|
|
Loading…
Add table
Reference in a new issue