加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
main.go 1.43 KB
一键复制 编辑 原始数据 按行查看 历史
neymar 提交于 2022-05-10 15:47 . post system
package main
//@title bluebell_backend
//@version 1.0
//@description news_app 测试
//@termsOfService http://swagger.io/terms/
//
//@contact.name author:@lxj
//@contact.url http://www.swagger.io/support
//@contact.email support@swagger.io
//
//@license.name Apache 2.0
//@license.url http://www.apache.org/licenses/LICENSE-2.0.html
//
//@host 127.0.0.1:8081
//@BasePath /api/v1/
import (
"fmt"
"news/dao/mysql"
"news/dao/redis"
"news/logger"
"news/pkg/snowflake"
"news/routes"
"news/settings"
"go.uber.org/zap"
)
func main() {
if err := settings.Init(); err != nil {
fmt.Printf("init settings failed err %s\n", err)
return
}
if err := logger.Init(settings.Conf.LogConfig, settings.Conf.Mode); err != nil {
fmt.Printf("init logger failed err %s\n", err)
return
}
defer zap.L().Sync()
zap.L().Debug("logger init success")
if err := mysql.Init(settings.Conf.MySQLConfig); err != nil {
fmt.Printf("init mysql failed err %s\n", err)
return
}
defer mysql.Close()
if err := redis.Init(); err != nil {
fmt.Printf("init redis failed err %s\n", err)
return
}
defer redis.Close()
if err := snowflake.Init(settings.Conf.StartTime, settings.Conf.MachineID); err != nil {
fmt.Printf("init snowflake failed, err:%v\n", err)
return
}
// 注册路由
r := routes.Setup(settings.Conf.Mode)
err := r.Run(fmt.Sprintf(":%d", settings.Conf.Port))
if err != nil {
fmt.Printf("run server failed, err:%v\n", err)
return
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化