使用gorm建立多對多關系時,發現沒有成功,報錯:Error 1075: Incorrect table definition; there can be only one auto column and it must be defined as a key
查看代碼發現在,我的兩個主表的ID都寫了type:int(11) unsigned auto_increment;
我使用的是mysql,不能有多個自增長的列。
參考gorm.Model的寫法,於是把ID改`gorm:"primary_key;comment:記錄ID;"`
問題就解決了。