run_server.go 613 B

1234567891011121314151617181920212223242526
  1. package core
  2. import (
  3. "fmt"
  4. "hongze/hongze_google_api/global"
  5. "hongze/hongze_google_api/init_serve"
  6. )
  7. func RunServe() {
  8. //初始化路由
  9. r := init_serve.InitRouter()
  10. //初始化验证器
  11. if err := global.InitTrans("zh"); err != nil {
  12. fmt.Println("init trans failed, err:%v\n", err)
  13. return
  14. }
  15. fmt.Println("run server start")
  16. fmt.Println("run server:", global.CONFIG.Serve.Port)
  17. err := r.Run(fmt.Sprint("0.0.0.0:", global.CONFIG.Serve.Port)) // 监听并在 0.0.0.0:8080 上启动服务
  18. if err != nil {
  19. panic(fmt.Errorf("服务启动失败,Err:%s", err))
  20. }
  21. fmt.Println("run server end")
  22. }