type Foo struct {
A string
B int64
C bool
D string
}
src := Foo{
A: "a",
B: 52,
C: false,
D: "2012-02-02",
}
dest := Foo{
A: "b",
B: 12,
C: true,
D: "2012-02-03",
}
mergo.Merge(&dest, src, mergo.WithOverride)
fmt.Println(src)
fmt.Println(dest)
fmt.Printf("%+v", dest)
got
{a 52 false 2012-02-02}
{a 52 true 2012-02-02}
{A:a B:52 C:true D:2012-02-02}
expected
{a 52 false 2012-02-02}
{a 52 false 2012-02-02}
{A:a B:52 C:false D:2012-02-02}
type Foo struct {
A string
B int64
C bool
D string
}
src := Foo{
A: "a",
B: 52,
C: true,
D: "2012-02-02",
}
dest := Foo{
A: "b",
B: 12,
C: false,
D: "2012-02-03",
}
mergo.Merge(&dest, src, mergo.WithOverride)
fmt.Println(src)
fmt.Println(dest)
fmt.Printf("%+v", dest)
got
{a 52 true 2012-02-02}
{a 52 true 2012-02-02}
{A:a B:52 C:true D:2012-02-02}
expected
{a 52 true 2012-02-02}
{a 52 true 2012-02-02}
{A:a B:52 C:true D:2012-02-02}
As you can see overriding true with false
fails, however overriding false with true
works
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too