🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Sign inDemoInstall
Socket

github.com/peterbourgon/mergemap

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/peterbourgon/mergemap

v0.0.1
Source
Go
Version published
Created
Source

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 := mergemap.Merge(m1, m2)

See the test file for some pretty straightforward examples.

FAQs

Package last updated on 13 Jun 2013

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts