diff --git a/config.example.toml b/config.example.toml new file mode 100644 index 0000000..45a6a61 --- /dev/null +++ b/config.example.toml @@ -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" \ No newline at end of file diff --git a/initialize/setup.go b/initialize/setup.go index a51801a..a612ca0 100644 --- a/initialize/setup.go +++ b/initialize/setup.go @@ -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" ) @@ -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() + } }