代码拉取完成,页面将自动刷新
// Package ldflags
// @Link https://gitee.com/linngc/center.gf
// @Copyright Copyright (c) 2022 center CLI
// @Author linngc
// @License
package ldflags
import (
"context"
"github.com/gogf/gf/v2"
"github.com/gogf/gf/v2/os/gbuild"
"github.com/gogf/gf/v2/os/gtime"
"runtime"
)
// 编译时 指定程序信息
// 编译 go build -ldflags="-X center.gf/utility/ldflags.BuildGitCommit=`git rev-parse --abbrev-ref HEAD` -X center.gf/utility/ldflags.BuildGoTime=`date +'%Y-%m-%d.%H:%M:%S'`"
type BuildInfo struct {
GoFrame string // 编译部署使用:gf版本
Golang string // 编译部署使用:golang版本
Time string // 编译部署使用:编译时间
}
// Info 获取程序编译信息(注意:开发调试时,无法获取到gbuild包的变量信息)
func Info(ctx context.Context) *BuildInfo {
gfInfo := gbuild.Info()
var (
golang = gfInfo.Golang
goFrame = gfInfo.GoFrame
buildTime = gfInfo.Time
)
if len(golang) == 0 {
golang = runtime.Version()
}
if len(goFrame) == 0 {
goFrame = gf.VERSION
}
if len(buildTime) == 0 {
buildTime = gtime.Now().String()
}
return &BuildInfo{GoFrame: goFrame, Golang: golang, Time: buildTime}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。