jinzhu / copier

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

Unexported struct fields which are pointers are not deep copied #212

Open anandsunderraman opened 3 months ago

anandsunderraman commented 3 months ago

Reproducible Example

https://go.dev/play/p/xa2-zmGBrU9

Description

Refer to the example above.

type Address struct {
    Street string
    City   string
}

type Person struct {
    Name string
    Age  int
    addr *Address
}

If a struct has an unexported field and if it is a pointer then DeepCopy of this unexported pointer does not happen.