From 399f124290d6f29165c5dbf27ca494702d433416 Mon Sep 17 00:00:00 2001 From: gagliardetto Date: Fri, 9 Jun 2023 14:56:10 +0200 Subject: [PATCH] Add more info --- cmd/radiance/car/dump2/main.go | 18 ++++++++++++++++++ cmd/radiance/main.go | 32 +++++++++++++++++++++++++++++++- 2 files changed, 49 insertions(+), 1 deletion(-) diff --git a/cmd/radiance/car/dump2/main.go b/cmd/radiance/car/dump2/main.go index 959d00b..db33af3 100644 --- a/cmd/radiance/car/dump2/main.go +++ b/cmd/radiance/car/dump2/main.go @@ -8,6 +8,7 @@ import ( "io" "io/fs" "os" + "runtime/debug" "sort" "strconv" "strings" @@ -68,6 +69,23 @@ func main() { fmt.Printf("Dump tool for Solana CAR files.\n") fmt.Printf("Tag/Branch: %s\n", GitTag) fmt.Printf("Commit: %s\n", GitCommit) + if info, ok := debug.ReadBuildInfo(); ok { + fmt.Printf("More info:\n") + for _, setting := range info.Settings { + if isAnyOf(setting.Key, + "-compiler", + "GOARCH", + "GOOS", + "GOAMD64", + "vcs", + "vcs.revision", + "vcs.time", + "vcs.modified", + ) { + fmt.Printf(" %s: %s\n", setting.Key, setting.Value) + } + } + } os.Exit(0) } var flagPrintFilter string diff --git a/cmd/radiance/main.go b/cmd/radiance/main.go index 7cd35c8..68d8e3f 100644 --- a/cmd/radiance/main.go +++ b/cmd/radiance/main.go @@ -4,8 +4,10 @@ package main import ( "context" "flag" + "fmt" "os" "os/signal" + "runtime/debug" "github.com/spf13/cobra" "go.firedancer.io/radiance/cmd/radiance/blockstore" @@ -49,10 +51,38 @@ var ( GitTag string ) +func isAnyOf(s string, anyOf ...string) bool { + for _, v := range anyOf { + if s == v { + return true + } + } + return false +} + var versionCmd = cobra.Command{ Use: "version", Short: "Print the version number of Radiance", Run: func(cmd *cobra.Command, args []string) { - klog.Infof("Radiance built from tag/branch %q (commit: %s)", GitTag, GitCommit) + fmt.Printf("Radiance.\n") + fmt.Printf("Tag/Branch: %s\n", GitTag) + fmt.Printf("Commit: %s\n", GitCommit) + if info, ok := debug.ReadBuildInfo(); ok { + fmt.Printf("More info:\n") + for _, setting := range info.Settings { + if isAnyOf(setting.Key, + "-compiler", + "GOARCH", + "GOOS", + "GOAMD64", + "vcs", + "vcs.revision", + "vcs.time", + "vcs.modified", + ) { + fmt.Printf(" %s: %s\n", setting.Key, setting.Value) + } + } + } }, }