darccio/mergo

Details on which fields/attributes were updated

Closed this issue · 4 comments

Hi, is there perhaps a way to see which fields have been updated after a merge?

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

Is this something that is of relevance to this project @imdario? If so, I am happy to contribute to this.

To expand on my understanding of what @jankrynauw is seeking using the demo:

src := Foo{
	A: "one",
	B: 2,
}
dest := Foo{
	A: "two",
}
mergo.Merge(&dest, src)
fmt.Println(dest)
// Will print
// {two 2}

It would be useful to have a way to know that field A comes from dest and field B from src.

My suggestion would be to have a map[string]string with the keys being the struct's field paths and the value being the name of the relevant struct. In this example:

map[string]int32{
	"A":       "dest",
	"B":      "src",
}

@ruanspies Not sure about this change.

Closing. Maybe it could be considered for v2, but I don't see a real value that outweights the effort to track all merges.