-
-
Notifications
You must be signed in to change notification settings - Fork 274
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Invalid merge of two map[string]interface{} #91
Comments
Result with |
i've just discovered the same issue. is this intended? |
@imdario any updates? |
@dshylov From README |
@0x1mason, actually, maps are more flexible. Both maps have the same type map[string]interface{} so they should count as "same-type maps" but I'll check it. |
I found the same. This breaks the idea and "contract" implemented here: https://github.com/Masterminds/sprig/blob/master/dict.go#L80 I whipped up an example that shows the unexpected behaviour: package main
import (
"fmt"
"github.com/imdario/mergo"
)
func main() {
map1 := map[string]interface{}{
"deep": map[string]interface{}{
"enabled": true,
},
"key": "default",
}
map2 := map[string]interface{}{
"deep": map[string]interface{}{
"enabled": false,
},
"key": "overwritten",
}
mergo.Merge(&map1, map2)
fmt.Println(map1)
} Expected output
Actual output$ go get -u github.com/imdario/mergo
map[deep:map[enabled:true] key:default] |
@Overbryd if you use
This will print |
@vdemeester thanks, I can confirm that |
Merge of
will returns
map[first:1]
The text was updated successfully, but these errors were encountered: