This commit is contained in:
孟帅
2022-11-24 23:37:34 +08:00
parent 4ffe54b6ac
commit 29bda0dcdd
1487 changed files with 97869 additions and 96539 deletions

View File

@@ -0,0 +1,42 @@
// Package global
// @Link https://github.com/bufanyun/hotgo
// @Copyright Copyright (c) 2022 HotGo CLI
// @Author Ms <133814250@qq.com>
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
//
package global
import (
"context"
"fmt"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/os/grpool"
"github.com/gogf/gf/v2/os/gtime"
"hotgo/internal/library/location"
"os"
)
func Init(ctx context.Context) {
// 默认上海时区
if err := gtime.SetTimeZone("Asia/Shanghai"); err != nil {
fmt.Printf("时区设置异常err%v \r\n", err)
return
}
RootPtah, _ = os.Getwd()
fmt.Printf("欢迎使用HotGo\r\n当前运行环境%v, 运行根路径为:%v \r\n", SysType, RootPtah)
loadMonitor(ctx)
}
func loadMonitor(ctx context.Context) {
err := grpool.AddWithRecover(ctx, func(ctx context.Context) {
MonitorData.STartTime = gtime.Now()
MonitorData.IntranetIP, _ = location.GetLocalIP()
MonitorData.PublicIP, _ = location.GetPublicIP()
})
if err != nil {
g.Log().Fatal(ctx, "global loadMonitor Fatal:", err)
return
}
}

View File

@@ -0,0 +1,21 @@
// Package global
// @Link https://github.com/bufanyun/hotgo
// @Copyright Copyright (c) 2022 HotGo CLI
// @Author Ms <133814250@qq.com>
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
//
package global
import (
"hotgo/internal/model"
"runtime"
)
var (
// RootPtah 运行根路径
RootPtah string
// SysType 操作系统类型 windows | linux
SysType = runtime.GOOS
// MonitorData 监控数据
MonitorData model.MonitorData
)