Skip to content

wwalker/mergemap

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mergemap

mergemap is a Go library to recursively merge JSON maps.

Build Status

Behavior

mergemap performs a simple merge of the src map into the dst map. That is, it takes the src value when there is a key conflict.

The only special behavior is when the conflicting key represents a map in both src and dst. Then, mergemap recursively descends into both maps, repeating the same logic. The max recursion depth is set by mergemap.MaxDepth.

Usage

var m1, m2 map[string]interface{}
json.Unmarshal(buf1, &m1)
json.Unmarshal(buf2, &m2)

merged, err := mergemap.Merge(m1, m2)

See the test file for some pretty straightforward examples.

About

Go library to recursively merge JSON maps

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%