增加版本显示

This commit is contained in:
2026-04-27 13:04:57 +08:00
parent 9f1a2b136d
commit 3495f5dac7
5 changed files with 78 additions and 2 deletions
+12
View File
@@ -12,6 +12,13 @@ import (
"github.com/goccy/go-yaml"
)
// 由 install.sh 编译时通过 -ldflags -X 注入
var (
GitVersion = "dev"
GitCommit = "unknown"
BuildTime = "unknown"
)
func main() {
fmt.Println("OPS Backend Service started")
@@ -101,6 +108,11 @@ func main() {
c.Abort()
})
// 将编译注入的版本信息传给 routers 包
routers.GitVersion = GitVersion
routers.GitCommit = GitCommit
routers.BuildTime = BuildTime
// API路由
routers.ApiRoot(r.Group("/api"))