Report real version info for go-install builds#6
Merged
Conversation
The version/commit/date variables are only injected by GoReleaser's ldflags, so binaries from go install (or plain go build) reported dev (commit: none, built: unknown) no matter what version they were. Go embeds the module version and VCS metadata in every binary; when the ldflags defaults are detected, --version now falls back to debug.ReadBuildInfo, so a fleet box always knows what it's running. GoReleaser-injected values still win when present.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: dd152d0fa4
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
A binary built from a tree with uncommitted changes reported the clean commit hash as if it matched exactly. The vcs.modified build setting now appends -dirty to the commit when the hash came from the VCS fallback; ldflags-injected values remain untouched.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
go install github.com/veteranbv/sysgreet/cmd/sysgreet@v1.2.0reportssysgreet dev (commit: none, built: unknown)— the version variables are only populated by GoReleaser's ldflags, whichgo installnever applies. On a fleet box that makes it impossible to tell what's actually deployed.Go embeds the module version and VCS metadata in every binary. When the ldflags defaults are detected,
--versionnow falls back todebug.ReadBuildInfo:go install …@v1.2.0→ reportsv1.2.0go buildin a checkout → reports the pseudo-version plus real commit hash and timestampVerified live: a plain
go buildof this branch reportssysgreet v1.1.1-0.20260715…+dirty (commit: c261b6d…, built: 2026-07-15T03:37:42Z)instead ofdev (none, unknown). Resolution logic is a pure function with table-driven tests covering all three build paths.Generated by Claude Code