Merge pull request #2 from xurwxj/f_support_different_type_set

mergeMaps support update diff type values
This commit is contained in:
Victor 2024-06-26 11:44:33 +08:00 committed by GitHub
commit 0c7eef9240
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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)")