fix(version): fall back to embedded build info when ldflags absent #130
Reference in New Issue
Block a user
Delete Branch "fix/version-buildinfo-fallback"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Found during rc.4 housekeeping:
go install gitea.lerkolabs.com/lerkolabs/uptop/cmd/uptop@v0.1.0-rc.4works (proxy.golang.org reaches Gitea — verified cold-cache), but the resulting binary reportsuptop devbecause version injection is GoReleaser-ldflags-only.Fix: an
init()readsdebug.ReadBuildInfo()when the ldflags defaults are untouched —info.Main.Versioncarries the requested module version for go-install builds, and vcs stamps fill commit/date for checkout builds. Feeds both--versionand the TUI footer (same var).0.1.0-rc.4 (sha, date)go install @tagdev0.1.0-rc.4go buildin checkoutdevprintVersionnow omits unknown commit/date instead of printing(none, unknown). Verified: release-sim ldflags build prints identically to today; local build prints stamped version; cmd tests + lint green.