From b44bbf020730de6c9404f36ebf2c78717d7e5772 Mon Sep 17 00:00:00 2001 From: Fede Barcelona Date: Thu, 4 Dec 2025 12:54:44 +0100 Subject: [PATCH] fix(cmd): retrieve version from build info in init() --- cmd/server/main.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/cmd/server/main.go b/cmd/server/main.go index c85e88a..dcb1aef 100644 --- a/cmd/server/main.go +++ b/cmd/server/main.go @@ -6,6 +6,7 @@ import ( "log/slog" "net/http" "os" + "runtime/debug" "strings" "github.com/spf13/cobra" @@ -18,6 +19,14 @@ import ( var Version = "dev" +func init() { + if Version == "dev" { + if info, ok := debug.ReadBuildInfo(); ok && info.Main.Version != "(devel)" { + Version = info.Main.Version + } + } +} + func main() { rootCmd := &cobra.Command{ Use: "sysdig-mcp-server",