version: document (devel) and pseudo-version build-info behavior

Clarify in resolveVersion why "(devel)" is skipped and what
info.Main.Version carries for tagged installs vs. builds on top of a
release, per review feedback on #3452.

Signed-off-by: Lrifton92 <Lrifton92@users.noreply.github.com>
This commit is contained in:
Lrifton92 2026-06-24 11:57:01 +02:00
parent b03d5127b3
commit fc2d4e81f1
1 changed files with 8 additions and 0 deletions

View File

@ -22,6 +22,14 @@ func resolveVersion(ldflagsVersion string, readBuildInfo func() (*debug.BuildInf
return ldflagsVersion return ldflagsVersion
} }
if info, ok := readBuildInfo(); ok && info != nil { if info, ok := readBuildInfo(); ok && info != nil {
// info.Main.Version is populated by the Go toolchain only for
// module-aware builds: it is the clean tag for an exact
// `@vX.Y.Z` install, or a synthesized pseudo-version
// (e.g. v7.15.4-0.20240115123456-abcdef123456) carrying the
// base version, commit timestamp and hash when built from
// commits on top of a release. A plain `go build` from a source
// checkout reports "(devel)", which we skip so release builds
// keep deferring to the ldflags value below.
if v := info.Main.Version; v != "" && v != "(devel)" { if v := info.Main.Version; v != "" && v != "(devel)" {
return v return v
} }