mergo
mergo copied to clipboard
Mergo: merging Go structs and maps since 2013
Here's an example ``` type Option struct { test bool } o := Option{} mergo.Merge(&o, &Option{test: true}) ``` In this example test will be false. WithOverride won't really work here,...
Hi, We are trying to do a custom merge on slices in our project. For simplicity I have used `IntSlice`(a custom type of slice of ints) in this example. The...
In some case, nil pointer merging should be skipped. This field could work with `WithOverwriteWithEmptyValue` to solve situation in https://github.com/imdario/mergo/issues/131, a false bool pointer will be merged and a nil...
> I will define some models, and I will also use protobuf. Sometimes their field types are different, so I want to customize the transformer according to the types of...
```go type TestStruct struct { ID string Deep map[string]interface{} } t0 := TestStruct{} t1 := TestStruct{ ID: "5", Deep: map[string]interface{}{"workers": map[string]interface{}{"num": 5}}, } mergo.Merge(&t0, t1) fmt.Printf("Address of t0.Deep['worker'] = %p\n",...
The behavior of merging with override enabled on pointers does not seem to be respected the same way as other types. I have highlighted the behavior in this go playground:...
Hiya, firstly, thank you for this project, of the bunch out there offering similar functionality this package is the only one I found that really does the job right and...
As mentioned in the title, the `struct` in map value is overwritten completely. I don't whether it is expected behaviour from the implementor's perspective. But the behaviour surprises me. See....
eg: Merge with WithOverride ``` package main import ( "fmt" "github.com/imdario/mergo" ) type Foo map[string]interface{} func main() { src := Foo{ "partners": []map[string]interface{}{ { "common": "common_field", "enabled": true, }, {...
See https://go.dev/play/p/wUmW7O4Fr5s. If "x" is overridden (which is what I would expect), I don't see why "y" isn't.