How to clone a structure with unexported field?
问题 If I have a type defined as: type T struct { S string is []int } then how can I go about cloning an object of this type? If I do a simple assignment: p := T{"some string", []int{10, 20}} q := p Then any changes made to the []int affect both objects. Since T.is is not exported, it cannot be copied over explicitly, even if extracted using reflect. I'm currently supplying a Clone method in the package of the type itself. But that doesn't help with similar types in other packages. Is there