Skip to content

sridharavinash/deepmerge

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Inspired by deep_merge in rails.

Typical usage:

	map1 := map[string]int{
		"a": 10,
		"b": 3,
		"c": 12,
	}

	map2 := map[string]int{
		"a": 3,
		"b": 3,
		"c": 2,
	}

    add := func(a, b int) int { return a + b }
    d := &DeepMerge{
         map1: map1,
         map2: map2,
    }
    mergedMap, err := d.Merge(&add)

Expected Output(mergedMap):

	 map[string]int{
		"a": 13,
		"b": 6,
		"c": 14,
	}

There are more examples in deepmerge_test.go

Installation

go get -u github.com/sridharavinash/deepmerge

Tests

go test ./...

About

Merge 2 maps based on the function provided.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published