Closed borystomala closed 8 years ago
Hi,
if you've got fields with same name but different types, Copy panics due to attempt to assign value of wrong type.
type TypeStruct1 struct { Field1 string Field2 string } type TypeStruct2 struct { Field1 int Field2 string } func main() { ts := &TypeStruct1 { Field1: "str1", Field2: "str2", } ts2 := &TypeStruct2 {} Copy(ts2, ts) // panic! }
This PR fixes this by checking if types are assignable (eg. string => string, string => interface{}).
I like this feature!
Hi,
if you've got fields with same name but different types, Copy panics due to attempt to assign value of wrong type.
This PR fixes this by checking if types are assignable (eg. string => string, string => interface{}).