main.go 997 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. package main
  2. import (
  3. "Panel_development/app"
  4. "Panel_development/database"
  5. "Panel_development/global"
  6. "Panel_development/simple_zap"
  7. "Panel_development/unity"
  8. "context"
  9. )
  10. func init() {
  11. err := global.SetupSetting()
  12. if err != nil {
  13. simple_zap.WithCtx(context.Background()).Sugar().Warn(err, "配置文件读取失败")
  14. }
  15. err = global.SetupDBLink()
  16. if err != nil {
  17. simple_zap.WithCtx(context.Background()).Sugar().Warn(err, "数据库连接失败")
  18. }
  19. // 数据库迁移
  20. database.Migrate(global.DBLink)
  21. //本地化
  22. if err = unity.Translator("zh"); err != nil {
  23. simple_zap.WithCtx(context.Background()).Sugar().Warn(err, "注册本地化失败")
  24. }
  25. }
  26. // @title 面板开发
  27. // @version 1.0
  28. // @description 面板开发
  29. // @Host 127.0.0.1:8081
  30. // @BasePath /api
  31. //
  32. //go:generate swag init --parseDependency --parseDepth=6
  33. func main() {
  34. err := app.InitRouter()
  35. if err != nil {
  36. simple_zap.WithCtx(context.Background()).Sugar().Warn(err, "项目初始化失败")
  37. return
  38. }
  39. }