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

有异常panic #82

Open
icetech233 opened this issue Mar 10, 2024 · 3 comments
Open

有异常panic #82

icetech233 opened this issue Mar 10, 2024 · 3 comments

Comments

@icetech233
Copy link

getColumnNameMap

@icetech233
Copy link
Author

reflect: call of reflect.Value.NumField on ptr Value
/usr/lib/go-1.20/src/reflect/value.go:223 (0x4c656c)
flag.mustBe: panic(&ValueError{valueMethodName(), f.kind()})
/usr/lib/go-1.20/src/reflect/value.go:2041 (0x4c6502)
Value.NumField: v.mustBe(Struct)
/root/gocode/wms/vendor/github.com/acmestack/gorm-plus/gplus/cache.go:50 (0x9aa67e)
getColumnNameMap: for i := 0; i < valueOf.NumField(); i++ {
/root/gocode/wms/vendor/github.com/acmestack/gorm-plus/gplus/dao.go:129 (0x9ab1c4)

@icetech233
Copy link
Author

NumField 这个函数是不能随便调用的

@icetech233
Copy link
Author

推荐用这个

for _, f := range fields {
	// f.Index
	sfv := sv.FieldByName(f.Name)
	// get dst field by name
	dfv := dv.FieldByName(f.Name)

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

1 participant