Skip to content

Commit c7d2954

Browse files
authored
fix(cmd): retrieve version from build info in init() (#57)
1 parent cf9bc0b commit c7d2954

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

cmd/server/main.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"log/slog"
77
"net/http"
88
"os"
9+
"runtime/debug"
910
"strings"
1011

1112
"github.com/spf13/cobra"
@@ -18,6 +19,14 @@ import (
1819

1920
var Version = "dev"
2021

22+
func init() {
23+
if Version == "dev" {
24+
if info, ok := debug.ReadBuildInfo(); ok && info.Main.Version != "(devel)" {
25+
Version = info.Main.Version
26+
}
27+
}
28+
}
29+
2130
func main() {
2231
rootCmd := &cobra.Command{
2332
Use: "sysdig-mcp-server",

0 commit comments

Comments
 (0)