-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
40 lines (36 loc) · 745 Bytes
/
main.go
File metadata and controls
40 lines (36 loc) · 745 Bytes
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
package main
import (
"Goblog/core"
_ "Goblog/docs"
"Goblog/flag"
"Goblog/global"
"Goblog/routers"
)
// @title Goblog API文档
// @version 1.0
// @description Goblog API文档
// @host 127.0.0.1:8080
// @BasePath /
func main() {
//读取配置文件
core.InitConf()
//初始化日志
global.Log = core.InitLogger()
//连接数据库
global.DB = core.InitGorm()
//连接redis
global.Redis = core.ConnectRedis()
//命令行参数绑定
option := flag.Parse()
if flag.IsWebStop(option) {
flag.SwitchOption(option)
return
}
router := routers.InitRouter()
addr := global.Config.System.Addr()
global.Log.Infof("blog is running at: %s", addr)
err := router.Run(addr)
if err != nil {
global.Log.Fatalf(err.Error())
}
}