代码拉取完成,页面将自动刷新
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
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。