我匯入這段是這樣寫:
func InitDb() (err error) {
sqlF, err := os.ReadFile(define.SqlPath + sqlFName)
if err != nil {
return err
}
err = db.Exec(string(sqlF)).Error
if err != nil {
return err
}
return err
}
gorm會回覆我:
Error 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'SET NAMES utf8 */;\r\n/*!50503 SET NAMES utf8mb4 */;\r\n/*!40014 SET @OLD_FOREIGN...' at line 9
但我試著用HeidiSQL import是正常的
目前猜測可能是因為檔案轉移到linux產生的問題,我自己的做法是這樣:
1.windows HeidiSQL export sql file
2.sql file移至wsl中
3.postman打initdb這隻的api
golang程式與mariadb都是運行在wsl裡,只有HeidiSQL是執行在windows
請問我該怎麼做?