zhangqian
2023-11-15 03915064efe8fd7f222e4aac199af7e2d37deec6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package main
 
import (
    "go.uber.org/zap"
    "srm/api/v1/test"
 
    "srm/core"
    "srm/global"
    "srm/initialize"
)
 
//go:generate go env -w GO111MODULE=on
//go:generate go env -w GOPROXY=https://goproxy.cn,direct
//go:generate go mod tidy
//go:generate go mod download
 
// @title                       Swagger Example API
// @version                     0.0.1
// @description                 This is a sample Server pets
// @securityDefinitions.apikey  ApiKeyAuth
// @in                          header
// @name                        x-token
// @BasePath                    /
func main() {
    global.GVA_VP = core.Viper() // 初始化Viper
    global.GVA_LOG = core.Zap()  // 初始化zap日志库
    zap.ReplaceGlobals(global.GVA_LOG)
    global.GVA_DB = initialize.Gorm() // gorm连接数据库
    initialize.DBList()
    if global.GVA_DB != nil {
        initialize.RegisterTables() // 初始化表
        // 程序结束前关闭数据库链接
        db, _ := global.GVA_DB.DB()
        defer db.Close()
    }
 
    go test.InitProductServiceConn()
    defer test.CloseProductServiceConn()
    initialize.InitRpcClient()
    defer initialize.CloseRpcClient()
 
    core.RunWindowsServer()
}