From e865a0e2b04b9d9a4480bc5e4f4a2683c5e5c2cc Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Mon, 29 Jul 2024 19:23:26 -0700 Subject: [PATCH] cmd/tailscale/cli: add 'debug go-buildinfo' subcommand To dump runtime/debug.BuildInfo. Updates #1866 Change-Id: I8810390858a03b7649f9b22ef3ab910d423388da Signed-off-by: Brad Fitzpatrick --- cmd/tailscale/cli/debug.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/cmd/tailscale/cli/debug.go b/cmd/tailscale/cli/debug.go index f40859006..e98a9e078 100644 --- a/cmd/tailscale/cli/debug.go +++ b/cmd/tailscale/cli/debug.go @@ -22,6 +22,7 @@ import ( "os" "os/exec" "runtime" + "runtime/debug" "strconv" "strings" "time" @@ -330,9 +331,25 @@ var debugCmd = &ffcli.Command{ return fs })(), }, + { + Name: "go-buildinfo", + ShortUsage: "tailscale debug go-buildinfo", + ShortHelp: "Prints Go's runtime/debug.BuildInfo", + Exec: runGoBuildInfo, + }, }, } +func runGoBuildInfo(ctx context.Context, args []string) error { + bi, ok := debug.ReadBuildInfo() + if !ok { + return errors.New("no Go build info") + } + e := json.NewEncoder(os.Stdout) + e.SetIndent("", "\t") + return e.Encode(bi) +} + var debugArgs struct { file string cpuSec int