Documentation
¶
Overview ¶
Package buildinfo 在运行时暴露构建信息(版本 / commit / 构建时间 / Go 版本 / 模块 / 是否 dirty),用于 /version 端点、启动日志、诊断。零依赖(仅标准库)。
两个来源自动合并:
- ldflags 注入的包级变量(优先): go build -ldflags "-X github.com/rushteam/beauty/pkg/buildinfo.version=1.2.3 \ -X github.com/rushteam/beauty/pkg/buildinfo.commit=$(git rev-parse HEAD) \ -X github.com/rushteam/beauty/pkg/buildinfo.buildTime=$(date -u +%FT%TZ)"
- runtime/debug.ReadBuildInfo(回退):从 VCS 元数据取 revision/time/modified, 以及主模块路径与版本(go build 在 VCS 检出中会自动嵌入 vcs.*)。
未注入 ldflags 且非 VCS 构建时,尽力给出可用信息,Version 兜底 "unknown"。
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Handler ¶
func Handler() http.HandlerFunc
Handler 返回一个把构建信息以 JSON 输出的 http.Handler,可挂到 /version。
Types ¶
Click to show internal directories.
Click to hide internal directories.