-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
47 lines (38 loc) · 932 Bytes
/
main.go
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
44
45
46
47
package main
import (
"efeasy-gin/global"
"efeasy-gin/initialize"
)
func main() {
// 初始化配置
global.App.ConfigViper = initialize.Viper()
// 初始化日志
global.App.Logger = initialize.Zap("Default")
global.App.Logger.Info("Logger Init Success. ")
// 初始化数据库
global.App.DB = initialize.Gorm()
global.App.Logger.Info("Gorm Init Success. ")
// 程序关闭前,释放数据库连接
defer func() {
if global.App.DB != nil {
db, _ := global.App.DB.DB()
err := db.Close()
if err != nil {
panic(err)
}
}
}()
err := initialize.Validator("zh")
if err != nil {
panic(err)
}
global.App.Logger.Info("Validator Init Success. ")
// 初始化Redis
global.App.Redis = initialize.Redis()
global.App.Logger.Info("Redis Init Success. ")
// 7. 初始化minIO
initialize.MinIO()
// 启动服务器
initialize.RunServer()
global.App.Logger.Info("服务器启动成功. ")
}