From 5cc09e5c6c161195a8dd050a65bdaab1fed7cd03 Mon Sep 17 00:00:00 2001 From: Faissal Elamraoui Date: Sat, 22 Oct 2016 15:44:22 +0200 Subject: [PATCH] This fixes #295 --- banner.go | 2 +- version.go | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/banner.go b/banner.go index af33ef3..fefa37b 100644 --- a/banner.go +++ b/banner.go @@ -57,7 +57,7 @@ func show(out io.Writer, content string) { } err = t.Execute(out, vars{ - runtime.Version(), + getGoVersion(), runtime.GOOS, runtime.GOARCH, runtime.NumCPU(), diff --git a/version.go b/version.go index d9442aa..b95c3ea 100644 --- a/version.go +++ b/version.go @@ -6,8 +6,10 @@ import ( "fmt" "io" "os" + "os/exec" path "path/filepath" "regexp" + "strings" ) var cmdVersion = &Command{ @@ -114,3 +116,16 @@ func getBeegoVersion() string { } return "Beego not installed. Please install it first: https://github.com/astaxie/beego" } + +func getGoVersion() string { + var ( + cmdOut []byte + err error + ) + + if cmdOut, err = exec.Command("go", "version").Output(); err != nil { + fmt.Fprintln(os.Stderr, "There was an error running go version command:", err) + os.Exit(2) + } + return strings.Split(string(cmdOut), " ")[2] +}