Skip to content

Commit 6597963

Browse files
intel352claude
andcommitted
fix: use runtime/debug.BuildInfo for version when installed via go install
go install @tag now correctly reports the tag version instead of "dev". ldflags override still works for goreleaser/CI builds. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 6148a49 commit 6597963

2 files changed

Lines changed: 18 additions & 2 deletions

File tree

cmd/wfctl/main.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"log/slog"
1010
"os"
1111
"os/signal"
12+
"runtime/debug"
1213
"strings"
1314
"syscall"
1415
"time"
@@ -27,7 +28,14 @@ import (
2728
//go:embed wfctl.yaml
2829
var wfctlConfigBytes []byte
2930

30-
var version = "dev"
31+
var version = buildVersion()
32+
33+
func buildVersion() string {
34+
if info, ok := debug.ReadBuildInfo(); ok && info.Main.Version != "" && info.Main.Version != "(devel)" {
35+
return info.Main.Version
36+
}
37+
return "dev"
38+
}
3139

3240
// isHelpRequested reports whether the error originated from the user
3341
// requesting help (--help / -h). flag.ErrHelp propagates through the

cmd/workflow-lsp-server/main.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,19 @@ import (
66
"flag"
77
"fmt"
88
"os"
9+
"runtime/debug"
910

1011
"github.com/GoCodeAlone/workflow/lsp"
1112
)
1213

13-
var version = "dev"
14+
var version = buildVersion()
15+
16+
func buildVersion() string {
17+
if info, ok := debug.ReadBuildInfo(); ok && info.Main.Version != "" && info.Main.Version != "(devel)" {
18+
return info.Main.Version
19+
}
20+
return "dev"
21+
}
1422

1523
func main() {
1624
showVersion := flag.Bool("version", false, "Print version and exit")

0 commit comments

Comments
 (0)