fix: use generic dev version fallback#543
Closed
joshavant wants to merge 1 commit into
Closed
Conversation
Contributor
Author
|
Closing this in favor of a replacement PR that preserves the low-blast-radius fallback behavior while also using Go build metadata to report the installed module version for . |
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.
Summary
This changes the built-in fallback version from a stale release-like value (
0.13.0-dev) to a neutraldevvalue.Release builds already inject the real version, commit, and date through GoReleaser
ldflags, so this does not change the published release artifact behavior. It only affects binaries built without those linker flags, such as plaingo buildorgo install github.com/steipete/gogcli/cmd/gog@<version>.Why
The hardcoded fallback can drift after releases. When it does, source-installed binaries from a newer tag can report an older dev version, which makes support diagnostics and packaging verification misleading.
For example, a binary built from a tagged module version should not look like a stale
0.13.0-devbuild simply because it was not built through GoReleaser.Why This Change
Using
devis the lowest-blast-radius fix:A more complete future improvement could infer the module version from
runtime/debug.ReadBuildInfo()forgo install module@version, but this one-line change fixes the misleading output without changing release behavior.Verification
go test ./internal/cmdgo test ./cmd/goggo build -o /tmp/gog-dev ./cmd/gog && /tmp/gog-dev --versionprintsdevgo build -ldflags \"-X github.com/steipete/gogcli/internal/cmd.version=v9.9.9 -X github.com/steipete/gogcli/internal/cmd.commit=abc123 -X github.com/steipete/gogcli/internal/cmd.date=2026-05-01T00:00:00Z\" -o /tmp/gog-release ./cmd/gog && /tmp/gog-release --versionprintsv9.9.9 (abc123 2026-05-01T00:00:00Z)