1. 程式人生 > >[go error] Go 程式報錯:using unaddressable value

[go error] Go 程式報錯:using unaddressable value

一般出現 using unaddressable value 錯誤,表示傳遞的指標值不對,比如需要傳遞指標地址的,但是傳了值。

例子:

func main() {    db, _ := gorm.Open("mysql", "myproject:[email protected]/myproject?charset=utf8&parseTime=True")    db.AutoMigrate(Lorem{})}

應該:

db.AutoMigrate(&Lorem{})