Skip to content

Report the version from build info when ldflags are absent - #2

Merged
nicodes merged 1 commit into
mainfrom
report-version-from-build-info
Jul 30, 2026
Merged

Report the version from build info when ldflags are absent#2
nicodes merged 1 commit into
mainfrom
report-version-from-build-info

Conversation

@nicodes

@nicodes nicodes commented Jul 30, 2026

Copy link
Copy Markdown
Member

go install github.com/aviorstudio/gdam@v0.0.6 reported dev / none / unknown — only the release workflow passes -ldflags. The version was already in the module metadata Go stamps into every binary; nothing read it.

buildInfoVersion() fills in version, commit and date from debug.ReadBuildInfo() only when they're still at their defaults, so ldflags always win.

Verified both paths:

  • with release ldflags → gdam 9.9.9 / commit: abc123 (unchanged)
  • plain go buildgdam v0.0.6-0.20260730194825-df21bba81463 / commit: df21bba... (was dev / none / unknown)

🤖 Generated with Claude Code

Only the release workflow passes -ldflags, so a binary from
`go install github.com/aviorstudio/gdam@v0.0.6` reported "dev / none /
unknown". The version was already in the module metadata Go stamps into
every binary; nothing read it.

buildInfoVersion fills in version, commit, and date from debug.ReadBuildInfo
when they are still at their defaults, so released binaries are unchanged and
source-built ones stop lying.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@nicodes
nicodes merged commit 39f8eae into main Jul 30, 2026
1 check passed
@nicodes
nicodes deleted the report-version-from-build-info branch July 30, 2026 22:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant