cmd/tailscale/cli: add 'debug go-buildinfo' subcommand

To dump runtime/debug.BuildInfo.

Updates #1866

Change-Id: I8810390858a03b7649f9b22ef3ab910d423388da
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
pull/13356/head
Brad Fitzpatrick 3 months ago committed by Brad Fitzpatrick
parent 345876da33
commit e865a0e2b0

@ -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

Loading…
Cancel
Save