Open matthieujoossen opened 2 years ago
https://go.dev/play/p/eotrEMU7U2Z
My initial goal is to have a duplicate function.
I'm using this function (with a recover) in my production environment with copier version 0.3.4 without problem.
When I'm trying with 0.3.5 I have some troubles.
Firstly, is that my dpulicate function is not working anymore, but without understand why.
dpulicate
panic: reflect: call of reflect.Value.Type on zero Value goroutine 1 [running]: reflect.Value.Type({0x0, 0x0, 0xc00010e750}) /usr/local/go-faketime/src/reflect/value.go:2262 +0x12e github.com/jinzhu/copier.copier({0x4e6e20, 0xc0001083a0}, {0x4e7260, 0xc000106200}, {0x68, 0x9e, {0x0, 0x1, 0x5de0e0}}) /tmp/gopath4171674566/pkg/mod/github.com/jinzhu/copier@v0.3.5/copier.go:262 +0x2626 github.com/jinzhu/copier.CopyWithOption(...) /tmp/gopath4171674566/pkg/mod/github.com/jinzhu/copier@v0.3.5/copier.go:76 main.duplicate({0x4e7260, 0xc000106200}) /tmp/sandbox2567366000/prog.go:64 +0x265 main.main() /tmp/sandbox2567366000/prog.go:51 +0x265
In a more classic case, copying from a structure to another one (line 46), copier.CopyWithOption is working but not well.
copier.CopyWithOption
Indeed, elts field is not empty despite the `copier:"-"` tag.
elts
`copier:"-"`
Moreover, if I use copier.Copy instead of copier.CopyWithOption:
copier.Copy
UT
Reproducible Example
https://go.dev/play/p/eotrEMU7U2Z
Description
My initial goal is to have a duplicate function.
I'm using this function (with a recover) in my production environment with copier version 0.3.4 without problem.
When I'm trying with 0.3.5 I have some troubles.
Error 1
Firstly, is that my
dpulicate
function is not working anymore, but without understand why.Case 2
In a more classic case, copying from a structure to another one (line 46),
copier.CopyWithOption
is working but not well.Indeed,
elts
field is not empty despite the`copier:"-"`
tag.Moreover, if I use
copier.Copy
instead ofcopier.CopyWithOption
:UT
field is not emptyelts
field is not empty