main.go 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. package main
  2. import (
  3. _ "go.uber.org/automaxprocs"
  4. "go.uber.org/zap"
  5. "server/core"
  6. "server/global"
  7. "server/initialize"
  8. )
  9. //go:generate go env -w GO111MODULE=on
  10. //go:generate go env -w GOPROXY=https://goproxy.cn,direct
  11. //go:generate go mod tidy
  12. //go:generate go mod download
  13. // @title Gin-Vue-Admin Swagger API接口文档
  14. // @version v2.6.3
  15. // @description 使用gin+vue进行极速开发的全栈开发基础平台
  16. // @securityDefinitions.apikey ApiKeyAuth
  17. // @in header
  18. // @name x-token
  19. // @BasePath /
  20. // InitBackend initializes the Go backend (Viper, Zap, GORM, Gin) and starts the
  21. // HTTP server in a background goroutine. It does not block. Call this before
  22. // running the Wails application.
  23. func InitBackend() {
  24. global.GVA_VP = core.Viper()
  25. initialize.OtherInit()
  26. global.GVA_LOG = core.Zap()
  27. zap.ReplaceGlobals(global.GVA_LOG)
  28. global.GVA_DB = initialize.Gorm()
  29. initialize.Timer()
  30. initialize.DBList()
  31. if global.GVA_DB != nil {
  32. initialize.RegisterTables()
  33. }
  34. initialize.InitUHFDevices()
  35. go core.RunWindowsServer()
  36. }
  37. // main is retained for standalone (non-Wails) usage.
  38. func main() {
  39. InitBackend()
  40. // Block forever when running standalone.
  41. select {}
  42. }