gin框架查詢數據庫報錯 "created_at": unsupported Scan, storing driver.Value type []uint8 into type *time.Time

錯誤信息

sql: Scan error on column index 1, name "created_at": unsupported Scan, storing driver.Value type []uint8 into type *time.Time

解決方案

在連接數據庫的末尾加上parseTime=true,如下:

Db, err = gorm.Open("mysql", "username:password@tcp(127.0.0.1:3306)/gin?charset=utf8&parseTime=true")
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章