jinzhu / copier

Copier for golang, copy value from struct to struct and more
MIT License
5.58k stars 489 forks source link

DeepCopy is not handling interface pointers well #100

Open JonathanAquino opened 3 years ago

JonathanAquino commented 3 years ago

Reproducible Example

https://play.golang.org/p/x1EO_KR_ARr

Description

When I ask copier to DeepCopy a struct with a property that is an interface pointer, that property is not copied properly.

The expected output of the Golang Playground example above is:

*car.TireCount: 4
*car.CopyTireCount: 4

But the actual output is:

*car.TireCount: 4
*car.CopyTireCount: 824633787184
JonathanAquino commented 3 years ago

Note that the reprint deep-copy library does not have this problem:

https://play.golang.org/p/_vfUwBVw5oi

cc @qdm12

qdm12 commented 3 years ago

I think that's why I started that reprint library, as other libs wouldn't deep copy pointers properly... although I haven't touched in for more than a year, I have no idea how I coded that 😄