Skip to content

Commit

Permalink
add enable db config
Browse files Browse the repository at this point in the history
  • Loading branch information
gaochuwuhan committed Jun 20, 2022
1 parent d52504f commit 6a30635
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
36 changes: 36 additions & 0 deletions config.example.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
env = "dev"

[dev]
mysqlconn = "root:123456@tcp(127.0.0.1:33060)/cloud?charset=utf8mb4&parseTime=True&loc=Local"
redisconn = "127.0.0.1:63790"
redispasswd = "123456"
redisdb = 0
tcpNsqdAddr = "127.0.0.1:4150"
db_enable = true


[dev.log]
level = "info"
dir = "logs"
prefix = "[app]"
[dev.thirdpart.feishu]
app_id = "xx"
app_secret = "xx"


[prod]
mysqlconn = "root:123456@tcp(127.0.0.1:33060)/cloud?charset=utf8mb4&parseTime=True&loc=Local"
redisconn = "your-redis:6379"
redispasswd = "123"
redisdb = 7
tcpNsqdAddr = "10.210.93.201:4150"
db_enable = true


[prod.log]
level = "info"
dir = "logs"
prefix = "[app]"
[prod.thirdpart.feishu]
app_id = "xx"
app_secret = "xx"
5 changes: 4 additions & 1 deletion initialize/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"github.com/gaochuwuhan/goutils"
"github.com/gaochuwuhan/goutils/logger"
"github.com/gaochuwuhan/goutils/pkg/cafe"
"github.com/gaochuwuhan/goutils/pkg/serve"
)

Expand All @@ -22,6 +23,8 @@ func InitService(){
logger.Log=serve.Zap()
logger.Log.Sugar().Infof("[ =========== current env:%v ===========]",goutils.ENV)
//初始化全局mysql DB
goutils.DB=serve.GormMysql()
if goutils.VP.GetString(cafe.JoinStr(goutils.ENV,".db_enable")) == true{
goutils.DB=serve.GormMysql()
}

}

0 comments on commit 6a30635

Please sign in to comment.