gorm struct 查询报错:
unsupported Scan, storing driver.Value type []uint8 into type
问题原因:
数据库字段名称为大写:
例如:NAME
struct 定义也为大写:
例如:
type Demo struct {
NAME string `json:"NAME" gorm:"column:NAME"`
}
解决方案:
struct定义为小写:
type Demo struct {
NAME string `json:"name" gorm:"column:name"`
}