Merge pull request #37 from lwnmengjing/master

引入条件编译,选择性使用sqlite3
This commit is contained in:
wenjianzhang authored and GitHub committed 2020-04-18 10:41:34 +08:00
commit 9a70ea3d09
4 files changed
+27 -3

No files matched your search

+1
View File
@@ -6,3 +6,4 @@ temp/
!temp
vendor
config/settings.dev.yml
go-admin
+14
View File
@@ -0,0 +1,14 @@
PROJECT:=go-admin
.PHONY: build
build:
CGO_ENABLED=0 go build -o go-admin main.go
build-sqlite:
go build -tags sqlite3 -o go-admin main.go
#.PHONY: test
#test:
# go test -v ./... -cover
#.PHONY: docker
#docker:
# docker build . -t go-admin:latest
+5 -3
View File
@@ -4,8 +4,8 @@ import (
"bytes"
_ "github.com/go-sql-driver/mysql" //加载mysql
"github.com/jinzhu/gorm"
_ "github.com/jinzhu/gorm/dialects/sqlite"
"go-admin/tools/config"
config2 "go-admin/config"
"log"
"strconv"
)
@@ -52,7 +52,9 @@ func Setup() {
panic("db type unknow")
}
if err != nil {
log.Fatalln("%s connect error %v", DbType, err)
log.Fatalln("%s connect error %v", dbType, err)
} else {
log.Println("%s connect success!", dbType)
}
log.Println("%s connect success!", DbType)
+7
View File
@@ -0,0 +1,7 @@
// +build sqlite3
package database
import (
_ "github.com/jinzhu/gorm/dialects/sqlite"
)