Open RamVellanki opened 5 years ago
I was trying to use the copier to copy a struct but isn't working for me. Following is the code:
https://goplay.space/#ARoaaKRtM2K
type Cat struct { age int name string } func main() { firstCat := Cat{7, "Wilson"} secondCat := Cat{} copier.Copy(&secondCat, &firstCat) fmt.Println(firstCat) fmt.Println(secondCat) }
I expect the output to print {7, "Wilson"} two times but it prints {7, "Wilson"} {0 }.
Only exported fields are copied. I think because reflect can not set unreported fields.
reflect
I was trying to use the copier to copy a struct but isn't working for me. Following is the code:
https://goplay.space/#ARoaaKRtM2K
I expect the output to print {7, "Wilson"} two times but it prints {7, "Wilson"} {0 }.