当前位置:网站首页>When querying the database with Gorm, reflect: reflect flag. mustBeAssignable using unaddressable value
When querying the database with Gorm, reflect: reflect flag. mustBeAssignable using unaddressable value
2022-06-24 20:27:00 【russle】
Use gorm Wrote a little demo, Inserting and querying a single database displays correctly , In the query all The data is wrong .
error message
Key information :using unaddressable value
reflect: reflect.flag.mustBeAssignable using unaddressable value
C:/F/yqgopath/pkg/mod/github.com/jinzhu/[email protected]/scope.go:865 (0xb197a6)
(*Scope).callCallbacks.func1: panic(err)
C:/F/Go/src/runtime/panic.go:679 (0x430b8f)
gopanic: reflectcall(nil, unsafe.Pointer(d.fn), deferArgs(d), uint32(d.siz), uint32(d.siz))
C:/F/Go/src/reflect/value.go:247 (0x48f54e)
flag.mustBeAssignableSlow: panic("reflect: " + methodName() + " using unaddressable value")
C:/F/Go/src/reflect/value.go:234 (0x4957f1)
flag.mustBeAssignable: f.mustBeAssignableSlow()
C:/F/Go/src/reflect/value.go:1531 (0x4957d8)
Value.Set: v.mustBeAssignable()
C:/F/yqgopath/pkg/mod/github.com/jinzhu/[email protected]/callback_query.go:48 (0xad949d)
queryCallback: results.Set(reflect.MakeSlice(results.Type(), 0, 0))
C:/F/yqgopath/pkg/mod/github.com/jinzhu/[email protected]/scope.go:869 (0xb03218)
(*Scope).callCallbacks: (*f)(scope)
C:/F/yqgopath/pkg/mod/github.com/jinzhu/[email protected]/main.go:354 (0xaf0e6e)
(*DB).Find: return s.NewScope(out).inlineCondition(where...).callCallbacks(s.parent.callbacks.queries).db
C:/F/GoLandProjects/mygotutorials/ginconfigdemo/pkg/controller/user_controller.go:57 (0xb40d30)
(*UserController).GetAllUsers: result := c.db.Find(users)
C:/F/yqgopath/pkg/mod/github.com/gin-gonic/[email protected]/context.go:161 (0xa9bef1)
(*Context).Next: c.handlers[c.index](c)
C:/F/yqgopath/pkg/mod/github.com/gin-gonic/[email protected]/recovery.go:83 (0xab03ba)
RecoveryWithWriter.func1: c.Next()
C:/F/yqgopath/pkg/mod/github.com/gin-gonic/[email protected]/context.go:161 (0xa9bef1)
(*Context).Next: c.handlers[c.index](c)
C:/F/yqgopath/pkg/mod/github.com/gin-gonic/[email protected]/logger.go:241 (0xaaf4c7)
LoggerWithConfig.func1: c.Next()
C:/F/yqgopath/pkg/mod/github.com/gin-gonic/[email protected]/context.go:161 (0xa9bef1)
(*Context).Next: c.handlers[c.index](c)
C:/F/yqgopath/pkg/mod/github.com/gin-gonic/[email protected]/gin.go:409 (0xaa6653)
(*Engine).handleHTTPRequest: c.Next()
C:/F/yqgopath/pkg/mod/github.com/gin-gonic/[email protected]/gin.go:367 (0xaa5d44)
(*Engine).ServeHTTP: engine.handleHTTPRequest(c)
C:/F/Go/src/net/http/server.go:2802 (0x76e1fa)
serverHandler.ServeHTTP: handler.ServeHTTP(rw, req)
C:/F/Go/src/net/http/server.go:1890 (0x7699cb)
(*conn).serve: serverHandler{c.server}.ServeHTTP(w, w.req)
C:/F/Go/src/runtime/asm_amd64.s:1357 (0x45c1c0)
goexit: BYTE $0x90 // NOP
````
After careful comparison, it is found that the query input is not paper
```go
users := make([]model.User, 0)
// There's a problem here , I have been unable to query all the contents , Because I didn't use &users, But in and out users
result := c.db.Find(&users)
if result.Error != nil {
klog.Infof("failed to find all, err:%s", result.Error)
}
Error message screenshot 
边栏推荐
- Teach you how to view the number of connected people on WiFi in detail how to view the number of connected people on WiFi
- Application practice | massive data, second level analysis! Flink+doris build a real-time data warehouse scheme
- Bytebase joins Alibaba cloud polardb open source database community
- Apache+PHP+MySQL环境搭建超详细!!!
- Bytebase 加入阿里云 PolarDB 开源数据库社区
- 云计算发展的 4 个阶段,终于有人讲明白了
- Stackoverflow annual report 2022: what are developers' favorite databases?
- Where are Xiaomi mobile phone's favorite SMS and how to delete them
- Fundamentals of performance testing -- definitions of common terms
- 顺序栈1.0版本
猜你喜欢

Bytebase joins Alibaba cloud polardb open source database community

得物多活架构设计之路由服务设计

Some small requirements for SQL Engine for domestic database manufacturers

Bytebase joins Alibaba cloud polardb open source database community

Apple, Microsoft and Google will no longer fight each other. They will work together to do a big thing this year

Full link service tracking implementation scheme
![[R tidyverse] use of select verb](/img/2d/768391bc6ec497432915024bc90842.jpg)
[R tidyverse] use of select verb

Stackoverflow 年度报告 2022:开发者最喜爱的数据库是什么?

Confirm whether the host is a large terminal or a small terminal

苹果、微软、谷歌不再掐架,今年要合力干一件大事
随机推荐
Eureka source code shallow reading - automatic fault removal
Oracle create tablespaces and tables
Data backup and recovery of PgSQL
Dongyuhui is not enough to bring goods to "rescue" live broadcast
托管服务与SASE,纵享网络与安全融合 | 一期一会回顾
Introduction: continuously update the self-study version of the learning manual for junior test development engineers
Stackoverflow 年度报告 2022:开发者最喜爱的数据库是什么?
二叉树的基本性质与遍历
Cooking business experience of young people: bloggers are busy selling classes and bringing goods, and the organization earns millions a month
IP address to integer
基于SSM的物料管理系统(源码+文档+数据库)
别再用 System.currentTimeMillis() 统计耗时了,太 Low,StopWatch 好用到爆!
Fundamentals of performance testing -- definitions of common terms
What is CNN (convolutional neural network)
The name of the button in the Siyuan notes toolbar has changed to undefined. Has anyone ever encountered it?
16个优秀业务流程管理工具
Clustered index (clustered index), nonclustered index (nonclustered index)
物联网?快来看 Arduino 上云啦
2022年最新四川建筑八大员(电气施工员)模拟题库及答案
Some ideas about chaos Engineering