jinzhu / copier

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

Copy produces an error with gorm.Model #80

Closed matthieujoossen closed 3 years ago

matthieujoossen commented 3 years ago

Reproducible Example

https://play.golang.org/p/bONC5Pfw0V8

Description

Running this program produces an error (expected none):

panic: reflect: Field index out of range

goroutine 1 [running]:
reflect.Value.Field(0x5e0620, 0xc0001b5c00, 0x199, 0x3, 0x5e5a00, 0xc0001b5c00, 0x199)
    /usr/local/go-faketime/src/reflect/value.go:854 +0xd9
github.com/jinzhu/copier.copier(0x5b7f40, 0xc0001b5c00, 0x5b7f40, 0xc0001b5b90, 0x0, 0x5d39a0, 0xc000113e01)
    /tmp/gopath536822222/pkg/mod/github.com/jinzhu/copier@v0.2.4/copier.go:196 +0x17cd
github.com/jinzhu/copier.Copy(...)
    /tmp/gopath536822222/pkg/mod/github.com/jinzhu/copier@v0.2.4/copier.go:35
main.main()
    /tmp/sandbox082636651/prog.go:29 +0x1ab
matthieujoossen commented 3 years ago

It's ok with following code : https://play.golang.org/p/2TJ7Lvx_x5e

matthieujoossen commented 3 years ago

May help: https://play.golang.org/p/qSpYc2_pXbs