-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.go
52 lines (41 loc) · 934 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package main
import (
"errors"
"fmt"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/os/gctx"
"github.com/gogf/gf/v2/os/gtime"
"github.com/oldme-git/oldme-api/internal/cmd"
_ "github.com/gogf/gf/contrib/drivers/mysql/v2"
_ "github.com/oldme-git/oldme-api/internal/logic"
_ "github.com/oldme-git/oldme-api/internal/utility"
_ "github.com/oldme-git/oldme-api/utility/uinit"
)
const (
VERSION = "v1.5.1"
)
func main() {
var err error
fmt.Println(VERSION)
// 全局设置i18n
g.I18n().SetLanguage("zh-CN")
// 全局进程时间为Asia/shanghai
err = gtime.SetTimeZone("Asia/Shanghai")
if err != nil {
panic(err)
}
// 检查数据库是否能连接
err = connData()
if err != nil {
panic(err)
}
cmd.Main.Run(gctx.New())
}
// 检查数据库连接是否正常
func connData() error {
err := g.DB().PingMaster()
if err != nil {
return errors.New("连接到数据库失败")
}
return nil
}