Gin Gorm 查询遇到错误 storing driver.Value type []uint8 into type *time.Time
使用 gorm 查询数据时出错如下错误
sql: Scan error on column index 1, name "created_at": unsupported Scan, storing driver.Value type []uint8 into type *time.Time
解决方法
使用链接数据库时 dns 加上 &parseTime=true
dns := fmt.Sprintf(
"%s:%s@tcp(%s:%s)/%s?charset=utf8mb4&parseTime=true&loc=Local",
config.Db.User,
config.Db.Password,
config.Db.Host,
config.Db.Port,
config.Db.Database)
db, err := gorm.Open("mysql", dns)