Skip to content

fix(version): use debug.ReadBuildInfo for go-install builds#2

Merged
hushamsaeed merged 1 commit into
mainfrom
version-fallback
May 1, 2026
Merged

fix(version): use debug.ReadBuildInfo for go-install builds#2
hushamsaeed merged 1 commit into
mainfrom
version-fallback

Conversation

@hushamsaeed
Copy link
Copy Markdown
Contributor

Summary

go install github.com/plinth-dev/cli/cmd/plinth@v0.1.0 (the documented install path) bypasses the Makefile, so Version and Commit stayed empty and plinth version printed plinth dev (commit none, go1.X) — confusing for anyone trying to confirm what they installed.

This change adds a runtime/debug.ReadBuildInfo() fallback that reads the module version and vcs.revision setting Go's toolchain stamps into binaries. The Makefile path still takes precedence when both fields are set.

Test plan

  • CI passes on Go 1.25.
  • After merging and tagging v0.1.1, go install github.com/plinth-dev/cli/cmd/plinth@v0.1.1 should report a real version + commit.

🤖 Generated with Claude Code

When the binary is installed via `go install github.com/plinth-dev/cli/cmd/plinth@vX.Y.Z`
the Makefile ldflags don't run, so Version and Commit stay empty. Read
the module version + vcs.revision from runtime/debug.ReadBuildInfo so
those binaries report a real version instead of "dev (commit none)".
The Makefile-built path still wins when both fields are set explicitly.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@hushamsaeed hushamsaeed merged commit 3ed6430 into main May 1, 2026
1 check passed
@hushamsaeed hushamsaeed deleted the version-fallback branch May 1, 2026 13:48
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