type MaxIdStruct struct MaxId int64 jsonmaxId获取db最大的id取出来老是0请问下面sql有什么问题 maxIdVal = MaxIdStruct result = dbRawselect maxid as maxId from wemeet_agency_customerScan&maxIdVal
可能是因为没有给maxIdVal结构体的字段设置gorm的标签,导致无法正确解析查询结果。
可以尝试在MaxId字段上添加gorm的标签,如下所示:
type MaxIdStruct struct {
MaxId int64 json:"maxId" gorm:"column:maxId"
}
其中,column:maxId表示将查询结果中的maxId字段映射到结构体的MaxId字段上。
原文地址: https://www.cveoy.top/t/topic/hfQn 著作权归作者所有。请勿转载和采集!