package dict func softMerge(a, b Dict) { for k, v := range b { if a.HasKey(k) && IsDict(a[k]) && IsDict(v) { softMerge(a[k].(Dict), v.(Dict)) } else if !a.HasKey(k) { a[k] = v } } } func SoftMerge(target *Dict, source Dict) { if target == nil { *target = make(Dict) } softMerge(*target, source) } func (target *Dict) SoftMergeWith(source Dict) { if target == nil { *target = make(Dict) } softMerge(*target, source) } func merge(a, b Dict) { for k, v := range b { if a.HasKey(k) && IsDict(a[k]) && IsDict(v) { merge(a[k].(Dict), v.(Dict)) } else { a[k] = v } } } func Merge(target *Dict, source Dict) { if target == nil { *target = make(Dict) } merge(*target, source) } func (target *Dict) MergeWith(source Dict) { if target == nil { *target = make(Dict) } merge(*target, source) }