Skip to content

bool issue #249

Open
Open
@mybigman

Description

@mybigman
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

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.
Fund with Polar

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions