Doesn't deep-copy structs provided via pointers
bryndin opened this issue · 8 comments
bryndin commented
var user *User = &User{Name: "Jinzhu", Age: 18, Role: "Admin", Salary: 200000}
var newUser *User
err := copier.CopyWithOption(&newUser, &user, copier.Option{DeepCopy: true})
Gives copy destination is invalid
error.
voctior commented
var newUser *User = &User{}
harrisonho99 commented
You should check the error message return
err := copier.CopyWithOption(&newUser, &user, copier.Option{DeepCopy: true})
if err != nil {
panic(err)
}
uded commented
Sorry, but this isn't an error, and it is handled with an error message.
The problem exists in the second line of your example. This is messing up more with Golang than this library.
bryndin commented
@uded thanks. Would it be better to clarify why this error is happening, e.g.
if the destination is nil => "copy destination requires a non-nil pointer to a struct"
not just "invalid"
bryndin commented
yes, but it may take me some time to get to it.
uded commented
Probably less than for us here :-)
Will be waiting for your PR and reviewing it after we will get it ASAP...