update: 使用glebarez/sqlite替代gorm.io/driver/sqlite实现无需CGO运行

This commit is contained in:
2023-09-17 16:14:31 +08:00
parent 6b08b2cb86
commit be9bdd269e
3 changed files with 39 additions and 10 deletions

View File

@ -1,7 +1,7 @@
package database
import (
"gorm.io/driver/sqlite"
"github.com/glebarez/sqlite"
"gorm.io/gorm"
"sub2clash/model"
)
@ -9,7 +9,11 @@ import (
var DB *gorm.DB
func ConnectDB() error {
// 用上面的数据库连接初始化 gorm
db, err := gorm.Open(sqlite.Open("sub2clash.db"), &gorm.Config{})
if err != nil {
panic(err)
}
if err != nil {
return err
}