Created
May 10, 2019 07:36
-
-
Save hackerzhut/a0d7dfd06edc604c962c148314523556 to your computer and use it in GitHub Desktop.
Mege Maps
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func mergeMaps(x1, x2 map[string]interface{}) interface{} { | |
| for k, v2 := range x2 { | |
| if v1, ok := x1[k]; ok { | |
| if m1, ok := v1.(map[string]interface{}); ok { | |
| if m2, ok := v2.(map[string]interface{}); ok { | |
| x1[k] = mergeMaps(m1, m2) | |
| continue | |
| } | |
| } | |
| } | |
| x1[k] = v2 | |
| } | |
| return x1 | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment