-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmain.go
49 lines (43 loc) · 1.04 KB
/
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
48
49
/*
* @Descripttion: Main Function
* @Author: William Wu
* @Date: 2022-05-20 18:15:49
* @LastEditors: William Wu
* @LastEditTime: 2022-05-21 19:15:35
*/
package main
import (
"VideoHubGo/utils/LogUtils"
"os"
"github.com/gin-gonic/gin"
"github.com/spf13/viper"
router "VideoHubGo/router"
)
/**
* @Descripttion: 主函数 - Main Function
* @Author: William Wu
* @Date: 2022/05/23 下午 03:59
*/
func main() {
//读取配置文件 - Read The Configuration File
path, err := os.Getwd()
if err != nil {
LogUtils.Logger(err.Error())
}
config := viper.New()
config.AddConfigPath(path + "/configs")
config.SetConfigName("config")
config.SetConfigType("yaml")
//尝试进行配置读取 - Try Reading Configuration
if err := config.ReadInConfig(); err != nil {
LogUtils.Logger(err.Error())
}
port := config.GetString("http.port")
//Gin服务启动 - Running Gin Service
r := gin.Default()
r = router.Router(r)
err = r.Run(":" + port)
if err != nil {
LogUtils.Logger("服务启动失败 - Service Start Fail :" + err.Error())
}
}