Mabye有人有更简单的代码来执行sql文件由gorm lib?
// CARRIERS IMPORT
err := DB.Session.Model(model.Carriers{}).Count(&carriers).Error
if err != nil {
panic(err)
} else if carriers == 0 {
path, err := filepath.Abs("./dumps/carriers.sql")
if err != nil {
panic(err)
}
file, err := ioutil.ReadFile(path)
if err != nil {
panic(err)
}
DB.Session.Model(model.Carriers{}).Exec(string(file))
}