Skip to content

fix(version): report the module version after go install - #5

Merged
lroolle merged 1 commit into
mainfrom
fix/version-after-go-install
Aug 14, 2026
Merged

lroolle merged 1 commit into
mainfrom
fix/version-after-go-install

Conversation

@lroolle

@lroolle lroolle commented Aug 14, 2026

Copy link
Copy Markdown
Owner

Third install path, third finding. go install ...@latest works — it
pulled v0.2.0 from the proxy — but the binary reports:

$ /tmp/gobintest/bwg version
bwg dev

The release ldflags are not there, so main.version keeps its default.
That is not cosmetic: internal/updater compares versions numerically,
dev parses as 0.0.0, and every bwg update --check from a
go-installed binary announces an update that is already installed.

Go records the module version in binaries built that way, so
debug.ReadBuildInfo() answers it. A plain local go build still says
dev, because (devel) is not a version anyone can act on.

The decision is split into resolveVersion(stamped, buildinfo, ok) so
it can be tested without controlling how the test binary was built —
six cases including the pseudo-version go install ...@main produces.
cmd/bwg had no tests at all before this.

🤖 Generated with Claude Code

`go install github.com/lroolle/bwg-cli/cmd/bwg@latest` builds without
the release ldflags, so `bwg version` printed "dev". Not cosmetic: the
updater compares versions numerically, "dev" parses as 0.0.0, and every
`bwg update --check` then announced an update that was already
installed.

Go records the module version in binaries built that way, so ask
debug.ReadBuildInfo when the linker stamp is missing. A local `go
build` still reports dev, because "(devel)" is not a version anyone can
act on.

Found by running the README's other install line end to end.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@lroolle
lroolle merged commit 9453e2f into main Aug 14, 2026
5 checks passed
@lroolle
lroolle deleted the fix/version-after-go-install branch August 14, 2026 06: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