Merge arrays: Can't merge maps inside array
anveshcsgi opened this issue · 2 comments
anveshcsgi commented
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,
},
{
"name": "new_src_element",
"enabled": false,
},
},
}
dest := Foo{
"partners": []map[string]interface{}{
{
"common": "common_field",
"enabled": false,
},
{
"name": "new_dest_element",
"enabled": false,
},
},
}
mergo.Merge(&dest, src, mergo.WithOverride)
fmt.Println(dest)
}
got Output
map[partners:[map[common:common_field enabled:true] map[enabled:false name:new_src_element]]]
Expected Output
map[partners:[map[common:common_field enabled:true] map[enabled:false name:new_dest_element] map[enabled:false name:new_src_element]]]
Upvote & Fund
- We're using Polar.sh so you can upvote and help fund this issue.
- We receive the funding once the issue is completed & confirmed by you.
- Thank you in advance for helping prioritize & fund our backlog.
xscode-auto-reply commented
Thanks for opening a new issue. The team has been notified and will review it as soon as possible.
For urgent issues and priority support, visit https://xscode.com/imdario/mergo
darccio commented
This will be fixed in v2.