Skip to content

Instantly share code, notes, and snippets.

@hackerzhut
Created May 10, 2019 07:36
Show Gist options
  • Select an option

  • Save hackerzhut/a0d7dfd06edc604c962c148314523556 to your computer and use it in GitHub Desktop.

Select an option

Save hackerzhut/a0d7dfd06edc604c962c148314523556 to your computer and use it in GitHub Desktop.
Mege Maps
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