https://github.com/illarion/merge
Merge multiple maps in golang, recursively
https://github.com/illarion/merge
config go golang lodash-merge map mapstruct merge
Last synced: about 1 year ago
JSON representation
Merge multiple maps in golang, recursively
- Host: GitHub
- URL: https://github.com/illarion/merge
- Owner: illarion
- License: mit
- Created: 2023-05-01T12:26:22.000Z (almost 3 years ago)
- Default Branch: master
- Last Pushed: 2023-05-05T16:33:26.000Z (almost 3 years ago)
- Last Synced: 2025-01-07T10:31:32.066Z (about 1 year ago)
- Topics: config, go, golang, lodash-merge, map, mapstruct, merge
- Language: Go
- Homepage:
- Size: 2.93 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Merge
## Description
This is a simple library to merge two or more map[string]interface{} into one, recursively. It is useful when you need to merge two or more maps with different structures.
## Usage
```go
package main
import (
"fmt"
"github.com/illarion/merge"
"encoding/json"
)
func main() {
var src1 map[string]interface{}
var src2 map[string]interface{}
var src3 map[string]interface{}
json.Parse([]byte(`{"a": 1, "b": 2}`), &src1)
json.Parse([]byte(`{"c": 3, "d": 4}`), &src2)
json.Parse([]byte(`{"e": 5, "f": 6}`), &src3)
result := merge.Maps(nil, src1, src2, src3)
fmt.Sprintf("%#v", result)
}
```