mergo
mergo copied to clipboard
Merge with mergo.WithOverride gives unexpected behavior
package main
import (
"fmt"
"github.com/imdario/mergo"
)
type Foo struct {
A string
B int64
}
func main() {
src := Foo{
A: "one",
B: 2,
}
dest := Foo{
A: "two",
}
mergo.Merge(&dest, src, mergo.WithOverride)
fmt.Println(dest)
// Will print
// {one 2}
// Expect
// {two 2}
}
-
mergo.Merge(&dest, src, mergo.WithOverride)
gives{one 2}
-
mergo.Merge(&dest, src)
gives{two 2}
https://github.com/imdario/mergo/blob/29fb3d3bdc5512887f1dc9aedde6a0fed407fa8f/merge.go#L313
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
@mtt0 Why is it unexpected?