jinzhu / copier

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

Struct with pointers #12

Closed martijn-dd closed 7 years ago

martijn-dd commented 7 years ago

At the moment I am unable to copy struct A to struct B. It does not copy because this check: fromField.Type().AssignableTo(toField.Type()) on line 73 returns false. It is false because fromField type is *string and toField type is string. Is it possible to copy these two kind of structs?

type A struct {
    Title *string
    Description *string
    Status *bool
}
type B struct {
    Title string
    Description string
    Status bool
}
kchugalinskiy commented 7 years ago

You may try using my fork, I've added support for this and opened a pull request

martijn-dd commented 7 years ago

Thanks. I'll give it a try.

jinzhu commented 7 years ago

merged that PR, thank you @kchugalinskiy