Skip to content

fix(cli): report the module version when no ldflag stamped one - #9

Merged
eezzekl merged 1 commit into
mainfrom
fix/version-fallback
Oct 5, 2026
Merged

eezzekl merged 1 commit into
mainfrom
fix/version-fallback

Conversation

@eezzekl

@eezzekl eezzekl commented Oct 5, 2026

Copy link
Copy Markdown
Owner

Summary

  • go install binaries report skill-sync version dev because go install cannot receive the maintainer's -ldflags.
  • resolveVersion now prefers the GoReleaser ldflag and otherwise falls back to the module version from runtime/debug.ReadBuildInfo.
  • Diagnostics-only fix: the version string feeds Cobra's Version field and reaches no file the tool writes.

The bug

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

Homebrew, Scoop and tarball binaries are built by GoReleaser, which stamps -X main.version=, so they were unaffected.

Behavior

Build Reported version
GoReleaser (brew, scoop, tarball) ldflag value, unchanged
go install [email protected] module version, e.g. v1.1.1
Local go build VCS pseudo-version, e.g. v1.1.1-0.20261002231447-f9c2b733d696+dirty
go build -buildvcs=false dev

The 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

File Change
cmd/skill-sync/main.go Add resolveVersion(ldflagVersion, moduleVersion) with buildinfo fallback
cmd/skill-sync/version_test.go New table-driven test, 6 cases covering every row above

Verification

  • go test ./... passes (also verified with -race), plus go vet and gofmt -s.
  • Cross-compiled for the 6 GoReleaser targets; ldflag path checked with -ldflags "-X main.version=...".
  • Native review (reliability lens) approved.

`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".
@eezzekl eezzekl added the bug Something isn't working label Oct 5, 2026
@eezzekl
eezzekl merged commit ff7f267 into main Oct 5, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant