代码拉取完成,页面将自动刷新
package build
import (
"fmt"
"os"
"path/filepath"
"regexp"
"strconv"
"time"
)
var (
version = "v0.0.0-0-g00000000"
date = "20240730T18:30:00Z"
mode = "dev"
kind = ""
rc = "0"
patch = "0"
)
var Info buildInfo
func init() {
re := regexp.MustCompile(`v?(\d+\.\d+)(.*)-(\d+)-g([a-z0-9]{6,40})`)
if matches := re.FindStringSubmatch(version); len(matches) == 5 {
Info.Version = fmt.Sprintf("%s.%s%s", matches[1], patch, matches[2])
Info.GitCommit = matches[4]
Info.Revision, _ = strconv.Atoi(matches[3])
}
Info.BuildMode = mode
Info.Kind = kind
Info.BuildDate, _ = time.Parse("2006-01-02T15:04:05Z", date)
Info.Name = filepath.Base(os.Args[0])
Info.RC, _ = strconv.Atoi(rc)
}
type buildInfo struct {
Name string `json:"name"`
Kind string `json:"kind"`
Version string `json:"version"`
Revision int `json:"revision"`
GitCommit string `json:"git_commit"`
BuildMode string `json:"build_mode"`
BuildDate time.Time `json:"build_date"`
RC int `json:"rc"`
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。