Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/vojtechvitek/mergemaps
Go package for merging maps
https://github.com/vojtechvitek/mergemaps
Last synced: about 1 month ago
JSON representation
Go package for merging maps
- Host: GitHub
- URL: https://github.com/vojtechvitek/mergemaps
- Owner: VojtechVitek
- License: apache-2.0
- Created: 2014-10-15T11:31:25.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2014-12-03T19:05:56.000Z (about 10 years ago)
- Last Synced: 2024-10-14T09:26:08.483Z (3 months ago)
- Language: Go
- Homepage:
- Size: 691 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Go MergeMaps - Merge two maps
-----------------------------
This [Go (Golang)](http://golang.org/) package provides functions to merge two maps using [reflection](http://golang.org/pkg/reflect/).[![GoDoc](https://godoc.org/github.com/VojtechVitek/mergemaps?status.png)](https://godoc.org/github.com/VojtechVitek/mergemaps)
[![Travis](https://travis-ci.org/VojtechVitek/mergemaps.svg?branch=master)](https://travis-ci.org/VojtechVitek/mergemaps)This pkg was merged into [OpenShift 3](https://github.com/openshift/origin) [util pkg](https://github.com/openshift/origin/blob/master/pkg/util/mergemap.go).
Example
-------```
package mainimport (
map "github.com/VojtechVitek/mergemaps"
)func main() {
dst := map[string]string{"foo": "bar"}
src := map[string]string{"baz": ""}// Merge src map into dst map
err := mergemaps.MergeInto(dst, src, 0 /*flags*/)
if err != nil {
fmt.Errorf("Can't merge src into dst: %v", err)
}// Prints map[string]string{"baz":"", "foo":"bar"}
fmt.Printf("%#v\n", dst)
}
```See [more examples](examples/examples.go).
Flags
------ ErrorOnExistingDstKey
When set: Return an error if any of the dst keys is already set.
- ErrorOnDifferentDstKeyValue
When set: Return an error if any of the dst keys is already set to a different value than src key.
- OverwriteDstKey
When set: Overwrite existing dst key value with src key value.License
-------
Go MergeMaps is licensed under the [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0).