1 Star 0 Fork 2

安易科技(北京)有限公司/chameleon

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
build.go 1.02 KB
一键复制 编辑 原始数据 按行查看 历史
Derek Ray 提交于 2025-05-23 16:35 +08:00 . feat(build): update project build mechanism
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"`
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/anesec/chameleon.git
git@gitee.com:anesec/chameleon.git
anesec
chameleon
chameleon
205da4a0ed50

搜索帮助