main.go 963 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. package main
  2. import (
  3. "gin-vue-admin/core"
  4. "gin-vue-admin/global"
  5. "gin-vue-admin/gva/init_data"
  6. //"gin-vue-admin/gva/init_data"
  7. "gin-vue-admin/initialize"
  8. //"runtime"
  9. )
  10. // @title Swagger Example API
  11. // @version 0.0.1
  12. // @description This is a sample Server pets
  13. // @securityDefinitions.apikey ApiKeyAuth
  14. // @in header
  15. // @name x-token
  16. // @BasePath /
  17. func main() {
  18. switch global.GVA_CONFIG.System.DbType {
  19. case "mysql":
  20. initialize.Mysql()
  21. // case "sqlite":
  22. // initialize.Sqlite() // sqlite需要gcc支持 windows用户需要自行安装gcc 如需使用打开注释即可
  23. default:
  24. initialize.Mysql()
  25. }
  26. initialize.DBTables()
  27. if global.GVA_CONFIG.System.NeedInitData {
  28. init_data.InitData() // 通过配置文件初始化数据 默认为 false 首次运行需要将 ./config.yaml中 system下的 need-init-data 修改为true
  29. }
  30. // 程序结束前关闭数据库链接
  31. db, _ := global.GVA_DB.DB()
  32. defer db.Close()
  33. core.RunWindowsServer()
  34. }