Skip to content

Report real version info for go-install builds#6

Merged
veteranbv merged 2 commits into
mainfrom
fix/version-from-buildinfo
Jul 15, 2026
Merged

Report real version info for go-install builds#6
veteranbv merged 2 commits into
mainfrom
fix/version-from-buildinfo

Conversation

@veteranbv

Copy link
Copy Markdown
Owner

go install github.com/veteranbv/sysgreet/cmd/sysgreet@v1.2.0 reports sysgreet dev (commit: none, built: unknown) — the version variables are only populated by GoReleaser's ldflags, which go install never 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, --version now falls back to debug.ReadBuildInfo:

  • go install …@v1.2.0 → reports v1.2.0
  • local go build in a checkout → reports the pseudo-version plus real commit hash and timestamp
  • GoReleaser release binaries → unchanged, ldflags still win

Verified live: a plain go build of this branch reports sysgreet v1.1.1-0.20260715…+dirty (commit: c261b6d…, built: 2026-07-15T03:37:42Z) instead of dev (none, unknown). Resolution logic is a pure function with table-driven tests covering all three build paths.


Generated by Claude Code

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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread cmd/sysgreet/version.go
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.
@veteranbv
veteranbv merged commit 205045e into main Jul 15, 2026
4 checks passed
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