main.go 1.0 KB

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