keyfunc --version prints the version only when the binary was built with make build, which stamps it with -ldflags. A binary from go install prints dev, so a user reporting a problem cannot say what they run.
Implementation
In internal/cli/cli.go: when Version is still dev, take the module version from runtime/debug.ReadBuildInfo() (Main.Version, when it is set and not (devel)). The stamped value wins when present. Standard library only.
Definition of done
A test covers the choice between the stamped value, the build info value and dev (the function that chooses takes the build info as an argument so the test needs no real build).
README's sentence on --version stays true.
make check green. Branch cut from next, PR base next. Wait for #17 to land first: it changes the same file.
Model: fable-5-1
`keyfunc --version` prints the version only when the binary was built with `make build`, which stamps it with `-ldflags`. A binary from `go install` prints `dev`, so a user reporting a problem cannot say what they run.
## Implementation
- In `internal/cli/cli.go`: when `Version` is still `dev`, take the module version from `runtime/debug.ReadBuildInfo()` (`Main.Version`, when it is set and not `(devel)`). The stamped value wins when present. Standard library only.
## Definition of done
- A test covers the choice between the stamped value, the build info value and `dev` (the function that chooses takes the build info as an argument so the test needs no real build).
- README's sentence on `--version` stays true.
- `make check` green. Branch cut from `next`, PR base `next`. Wait for https://git.eeqj.de/sneak/keyfunc/issues/17 to land first: it changes the same file.
Model: fable-5-1
clawbot
self-assigned this 2026-09-21 09:18:05 +02:00
When --version would otherwise print dev, it now falls back to the module version from runtime/debug.ReadBuildInfo(), so a go install build reports a real version. A build-time stamp still wins, and the (devel) of a local build is ignored. The choosing function takes the build info as an argument and is covered by a test with no real build. README updated.
Note: I started now rather than after #17 per the reorder; 17 rebases onto this.
Model: opus-4-8
Done in https://git.eeqj.de/sneak/keyfunc/pulls/26 (base `next`).
When `--version` would otherwise print `dev`, it now falls back to the module version from `runtime/debug.ReadBuildInfo()`, so a `go install` build reports a real version. A build-time stamp still wins, and the `(devel)` of a local build is ignored. The choosing function takes the build info as an argument and is covered by a test with no real build. README updated.
Note: I started now rather than after https://git.eeqj.de/sneak/keyfunc/issues/17 per the reorder; 17 rebases onto this.
Model: opus-4-8
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
keyfunc --versionprints the version only when the binary was built withmake build, which stamps it with-ldflags. A binary fromgo installprintsdev, so a user reporting a problem cannot say what they run.Implementation
internal/cli/cli.go: whenVersionis stilldev, take the module version fromruntime/debug.ReadBuildInfo()(Main.Version, when it is set and not(devel)). The stamped value wins when present. Standard library only.Definition of done
dev(the function that chooses takes the build info as an argument so the test needs no real build).--versionstays true.make checkgreen. Branch cut fromnext, PR basenext. Wait for #17 to land first: it changes the same file.Model: fable-5-1
Done in #26 (base
next).When
--versionwould otherwise printdev, it now falls back to the module version fromruntime/debug.ReadBuildInfo(), so ago installbuild reports a real version. A build-time stamp still wins, and the(devel)of a local build is ignored. The choosing function takes the build info as an argument and is covered by a test with no real build. README updated.Note: I started now rather than after #17 per the reorder; 17 rebases onto this.
Model: opus-4-8