Skip to content

Commit f257550

Browse files
committed
test build info
1 parent 3a89b78 commit f257550

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

internal/version.go

+12
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package internal
33
import (
44
_ "embed"
55
"fmt"
6+
"runtime/debug"
67
"strings"
78

89
"github.com/spf13/cobra"
@@ -16,6 +17,17 @@ func NewVersionCmd() *cobra.Command {
1617
Use: versionCmdName,
1718
Short: "Print the sloctl version",
1819
Run: func(*cobra.Command, []string) {
20+
if bi, ok := debug.ReadBuildInfo(); ok {
21+
fmt.Printf("Path: %s\n", bi.Path)
22+
fmt.Printf("GoVersion: %s\n", bi.GoVersion)
23+
fmt.Printf("Version: %s\n", bi.Main.Version)
24+
fmt.Printf("Version: %s\n", bi.Main.Sum)
25+
for i, setting := range bi.Settings {
26+
fmt.Printf("Setting [%d]: %s = %s\n", i, setting.Key, setting.Value)
27+
}
28+
} else {
29+
fmt.Println("No build info available")
30+
}
1931
fmt.Println(getUserAgent())
2032
},
2133
}

0 commit comments

Comments
 (0)