From dfe8d36b9e3e739145310e5f6e98d6a170b54081 Mon Sep 17 00:00:00 2001 From: Andrew Nesbitt Date: Wed, 16 Sep 2026 08:58:22 +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. --- version.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/version.go b/version.go index 5695923..cfaa8c4 100644 --- a/version.go +++ b/version.go @@ -1,4 +1,15 @@ package pom +import "runtime/debug" + // Version is set via -ldflags at release time. var Version = "dev" + +func init() { + if Version != "dev" { + return + } + if bi, ok := debug.ReadBuildInfo(); ok && bi.Main.Version != "" && bi.Main.Version != "(devel)" { + Version = bi.Main.Version + } +}