From e64596f3058b665eeb341a768b75629f624b89d2 Mon Sep 17 00:00:00 2001 From: Andrew Nesbitt Date: Wed, 16 Sep 2026 09:07:29 +0100 Subject: [PATCH] Fall back to embedded build info for Version go install does not apply goreleaser's -ldflags -X, so binaries installed that way reported 'dev'. Read debug.BuildInfo.Main.Version when the ldflag is unset. --- internal/cli/version.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/internal/cli/version.go b/internal/cli/version.go index 35829ce..c264c7f 100644 --- a/internal/cli/version.go +++ b/internal/cli/version.go @@ -2,6 +2,7 @@ package cli import ( "fmt" + "runtime/debug" "github.com/spf13/cobra" ) @@ -17,5 +18,10 @@ var versionCmd = &cobra.Command{ } func init() { + if Version == "dev" { + if bi, ok := debug.ReadBuildInfo(); ok && bi.Main.Version != "" && bi.Main.Version != "(devel)" { + Version = bi.Main.Version + } + } rootCmd.AddCommand(versionCmd) }