Repository navigation
fix(cli): report the module version when no ldflag stamped one - #9
Merged
Merged
Conversation
`go install` cannot receive a maintainer's -ldflags: it compiles from the
module proxy with its own flags, so `main.version` kept its "dev" default
and `skill-sync --version` reported "dev" for every go-installed binary.
The version was never missing, only unsurfaced. The toolchain already
embeds it:
$ go version -m $(which skill-sync)
mod github.com/eezzekl/skill-sync v1.1.0
$ skill-sync --version
skill-sync version dev
resolveVersion now prefers the ldflag value, which GoReleaser stamps for
the Homebrew, Scoop and tarball binaries, and otherwise falls back to the
module version from runtime/debug.ReadBuildInfo.
No functional impact: the version string only feeds Cobra's Version field
and reaches no file the tool writes. This is a diagnostics fix, so that a
bug report identifies which build it came from.
Side effect worth noting: the toolchain stamps VCS state by default, so a
plain local build now reports a pseudo-version such as
v1.1.1-0.20261002231447-f9c2b733d696+dirty instead of "dev". That is kept
deliberately — it pins the exact commit and flags a dirty tree. Builds
with -buildvcs=false still report "dev".
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
go installbinaries reportskill-sync version devbecausego installcannot receive the maintainer's-ldflags.resolveVersionnow prefers the GoReleaser ldflag and otherwise falls back to the module version fromruntime/debug.ReadBuildInfo.Versionfield and reaches no file the tool writes.The bug
The version was never missing, only unsurfaced. The toolchain already embeds it:
Homebrew, Scoop and tarball binaries are built by GoReleaser, which stamps
-X main.version=, so they were unaffected.Behavior
go install [email protected]v1.1.1go buildv1.1.1-0.20261002231447-f9c2b733d696+dirtygo build -buildvcs=falsedevThe pseudo-version for local builds is kept deliberately: it pins the exact commit and flags a dirty tree, which is what a bug report needs.
Changes
cmd/skill-sync/main.goresolveVersion(ldflagVersion, moduleVersion)with buildinfo fallbackcmd/skill-sync/version_test.goVerification
go test ./...passes (also verified with-race), plusgo vetandgofmt -s.-ldflags "-X main.version=...".