运行时panic: invalid sql type (interface) in field Value for mysql
以下是我的gorm相关代码:
1.
type User struct {
gorm.DB
UserName string `gorm:"type:varchar(20);not null" json:"username"`
PassWord string `gorm:"type:varchar(20);not null" json:"password"`
Role int `gorm:"type:int" json:"role"`
}
2.
type Category struct {
gorm.DB
CaName string `gorm:"type:varchar(20);not null" json:"caname"`
}
3.
type Article struct {
Category Category
gorm.DB
Title string `gorm:"type:varchar(100);not null" json:"title"`
Cid int `gorm:"type: int" json:"cid"`
Desc string `gorm:"type:varchar(200);not null" json:"desc"`
Content string `gorm:"type:longtext" json:"content"`
Img string `gorm:"type:varchar(100)" json:"img"`
}