Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strange behaviour on sub-structures #130

Open
matthieujoossen opened this issue Mar 2, 2022 · 0 comments
Open

Strange behaviour on sub-structures #130

matthieujoossen opened this issue Mar 2, 2022 · 0 comments
Assignees

Comments

@matthieujoossen
Copy link

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.

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/[email protected]/copier.go:262 +0x2626
github.com/jinzhu/copier.CopyWithOption(...)
	/tmp/gopath4171674566/pkg/mod/github.com/jinzhu/[email protected]/copier.go:76
main.duplicate({0x4e7260, 0xc000106200})
	/tmp/sandbox2567366000/prog.go:64 +0x265
main.main()
	/tmp/sandbox2567366000/prog.go:51 +0x265

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 of copier.CopyWithOption:

  • UT field is not empty
  • elts field is not empty
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants