From b8e2c8f8a27fefe22056a676fee240c3799bd2f5 Mon Sep 17 00:00:00 2001 From: Andrew Nesbitt Date: Wed, 16 Sep 2026 09:09:05 +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. --- cmd/capcheck/app/app.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/cmd/capcheck/app/app.go b/cmd/capcheck/app/app.go index bf5b0e3..4fe8047 100644 --- a/cmd/capcheck/app/app.go +++ b/cmd/capcheck/app/app.go @@ -6,6 +6,7 @@ import ( "io" "os" "path/filepath" + "runtime/debug" "time" "github.com/git-pkgs/capcheck/internal/analyse" @@ -18,6 +19,15 @@ import ( 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 + } +} + type ExitError struct { Code int }