🎉 初始化项目
This commit is contained in:
51
server/main.go
Normal file
51
server/main.go
Normal file
@@ -0,0 +1,51 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"git.echol.cn/loser/st/server/core"
|
||||
"git.echol.cn/loser/st/server/global"
|
||||
"git.echol.cn/loser/st/server/initialize"
|
||||
_ "go.uber.org/automaxprocs"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
//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
|
||||
|
||||
// 这部分 @Tag 设置用于排序, 需要排序的接口请按照下面的格式添加
|
||||
// swag init 对 @Tag 只会从入口文件解析, 默认 main.go
|
||||
// 也可通过 --generalInfo flag 指定其他文件
|
||||
// @Tag.Name Base
|
||||
// @Tag.Name SysUser
|
||||
// @Tag.Description 用户
|
||||
|
||||
// @title Gin-Vue-Admin Swagger API接口文档
|
||||
// @version v2.8.9
|
||||
// @description 使用gin+vue进行极速开发的全栈开发基础平台
|
||||
// @securityDefinitions.apikey ApiKeyAuth
|
||||
// @in header
|
||||
// @name x-token
|
||||
// @BasePath /
|
||||
func main() {
|
||||
// 初始化系统
|
||||
initializeSystem()
|
||||
// 运行服务器
|
||||
core.RunServer()
|
||||
}
|
||||
|
||||
// initializeSystem 初始化系统所有组件
|
||||
// 提取为单独函数以便于系统重载时调用
|
||||
func initializeSystem() {
|
||||
global.GVA_VP = core.Viper() // 初始化Viper
|
||||
initialize.OtherInit()
|
||||
global.GVA_LOG = core.Zap() // 初始化zap日志库
|
||||
zap.ReplaceGlobals(global.GVA_LOG)
|
||||
global.GVA_DB = initialize.Gorm() // gorm连接数据库
|
||||
initialize.Timer()
|
||||
initialize.DBList()
|
||||
initialize.SetupHandlers() // 注册全局函数
|
||||
if global.GVA_DB != nil {
|
||||
initialize.RegisterTables() // 初始化表
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user