(dst, src map[string]interface{}, depth int)
| 15 | } |
| 16 | |
| 17 | func merge(dst, src map[string]interface{}, depth int) map[string]interface{} { |
| 18 | if depth > MaxDepth { |
| 19 | panic("too deep!") |
| 20 | } |
| 21 | for key, srcVal := range src { |
| 22 | if dstVal, ok := dst[key]; ok { |
| 23 | srcMap, srcMapOk := mapify(srcVal) |
| 24 | dstMap, dstMapOk := mapify(dstVal) |
| 25 | if srcMapOk && dstMapOk { |
| 26 | srcVal = merge(dstMap, srcMap, depth+1) |
| 27 | } |
| 28 | } |
| 29 | dst[key] = srcVal |
| 30 | } |
| 31 | return dst |
| 32 | } |
| 33 | |
| 34 | func mapify(i interface{}) (map[string]interface{}, bool) { |
| 35 | value := reflect.ValueOf(i) |