From 11df2bd9a6c02f28a5ca3a31477971bc61ec6618 Mon Sep 17 00:00:00 2001 From: Stephan Renatus Date: Tue, 6 Oct 2020 10:09:25 +0200 Subject: [PATCH] cmd/version: include golang version in output I've seen this in other tools and I thought it was useful. Signed-off-by: Stephan Renatus --- cmd/version.go | 1 + cmd/version_test.go | 4 +++- version/version.go | 7 +++++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/cmd/version.go b/cmd/version.go index 16a2c437bb..4e4eb88ed8 100644 --- a/cmd/version.go +++ b/cmd/version.go @@ -44,6 +44,7 @@ func generateCmdOutput(out io.Writer, check bool) { fmt.Fprintln(out, "Build Commit: "+version.Vcs) fmt.Fprintln(out, "Build Timestamp: "+version.Timestamp) fmt.Fprintln(out, "Build Hostname: "+version.Hostname) + fmt.Fprintln(out, "Go Version: "+version.GoVersion) if check { err := checkOPAUpdate(out) diff --git a/cmd/version_test.go b/cmd/version_test.go index 23b0ddb81f..cb211d3d9e 100644 --- a/cmd/version_test.go +++ b/cmd/version_test.go @@ -79,13 +79,15 @@ func setTestVersion() { version.Vcs = "12345" version.Timestamp = "2020-05-14T06:22:38Z" version.Hostname = "foo" + version.GoVersion = "1.14.7" } func getTestVersion() string { return "Version: v0.20.0\n" + "Build Commit: 12345\n" + "Build Timestamp: 2020-05-14T06:22:38Z\n" + - "Build Hostname: foo\n" + "Build Hostname: foo\n" + + "Go Version: 1.14.7\n" } func getTestServer(update interface{}, statusCode int) (baseURL string, teardownFn func()) { diff --git a/version/version.go b/version/version.go index bdfd4616fa..336aeb8acb 100644 --- a/version/version.go +++ b/version/version.go @@ -5,9 +5,16 @@ // Package version contains version information that is set at build time. package version +import ( + "runtime" +) + // Version is the canonical version of OPA. var Version = "0.24.0-dev" +// GoVersion is the version of Go this was built with +var GoVersion = runtime.Version() + // Additional version information that is displayed by the "version" command and used to // identify the version of running instances of OPA. var (