Skip to content

Commit 03e65bd

Browse files
fix: stop -version printing a double v prefix
git describe injects v0.7.0 and the format string already added a v, so release binaries printed subenum vv0.7.0. formatVersion trims the prefix so both the fallback and ldflags paths print subenum v0.7.0. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent f9b5003 commit 03e65bd

3 files changed

Lines changed: 23 additions & 2 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3636

3737
### Fixed
3838
- Structured output (`-format json` and `-format csv`) is now finalized only on the successful scan path. The finalizer previously ran via `defer` on every exit, so an early error (such as wildcard detection without `-force`) emitted an empty JSON array. Text output behavior is unchanged.
39+
- `-version` and the startup banner trim a leading `v` from the injected Version so `git describe` tags do not print as `subenum vv0.7.0`.
3940

4041
### Docs
4142
- Rewrote the ARCHITECTURE data-flow section to describe the dispatcher-owned work queue instead of the removed feed-then-close `subdomains` channel model, and corrected the DNS engine function descriptions.

‎main.go‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import (
2626
"fmt"
2727
"os"
2828
"os/signal"
29+
"strings"
2930
"syscall"
3031
"time"
3132

@@ -44,8 +45,13 @@ const (
4445

4546
// Version is the release identifier. go install builds keep this fallback;
4647
// Makefile and CI override it with -ldflags "-X main.Version=$(git describe --tags --dirty)".
48+
// formatVersion trims a leading "v" so a tag like v0.7.0 does not print as vv0.7.0.
4749
var Version = "0.7.0"
4850

51+
func formatVersion() string {
52+
return ProgramName + " v" + strings.TrimPrefix(Version, "v")
53+
}
54+
4955
func main() {
5056
// Fast-path: if -tui is the first argument, launch the TUI immediately
5157
// before flag.Parse() consumes everything else.
@@ -170,7 +176,7 @@ func openOutputFile(path string, testMode bool, format output.Format, out *outpu
170176
}
171177

172178
func logVerboseStart(f cliFlags, domain string, maxAttempts int, out *output.Writer) {
173-
out.Info("Starting %s v%s", ProgramName, Version)
179+
out.Info("Starting %s", formatVersion())
174180
if f.testMode {
175181
out.Info("Mode: SIMULATION (no actual DNS queries)")
176182
out.Info("Simulated hit rate: %d%%", f.testHitRate)
@@ -243,7 +249,7 @@ func run() int {
243249
}
244250

245251
if f.showVersion {
246-
fmt.Printf("%s v%s\n", ProgramName, Version)
252+
fmt.Println(formatVersion())
247253
if f.testMode {
248254
fmt.Println("Running in SIMULATION mode")
249255
}

‎main_test.go‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,17 @@ func TestResolveAttempts(t *testing.T) {
2222
t.Error("both set: expected error, got nil")
2323
}
2424
}
25+
26+
func TestFormatVersion(t *testing.T) {
27+
old := Version
28+
t.Cleanup(func() { Version = old })
29+
30+
Version = "0.7.0"
31+
if got := formatVersion(); got != "subenum v0.7.0" {
32+
t.Errorf("fallback: got %q", got)
33+
}
34+
Version = "v0.7.0"
35+
if got := formatVersion(); got != "subenum v0.7.0" {
36+
t.Errorf("git describe tag: got %q", got)
37+
}
38+
}

0 commit comments

Comments
 (0)