1
0
mirror of https://github.com/beego/bee.git synced 2024-11-22 15:10:54 +00:00

Merge pull request #296 from amrfaissal/fix-goversion

Fix GoVersion value
This commit is contained in:
astaxie 2016-10-24 10:20:35 +08:00 committed by GitHub
commit 50fafd72e8
2 changed files with 16 additions and 1 deletions

View File

@ -57,7 +57,7 @@ func show(out io.Writer, content string) {
} }
err = t.Execute(out, vars{ err = t.Execute(out, vars{
runtime.Version(), getGoVersion(),
runtime.GOOS, runtime.GOOS,
runtime.GOARCH, runtime.GOARCH,
runtime.NumCPU(), runtime.NumCPU(),

View File

@ -6,8 +6,10 @@ import (
"fmt" "fmt"
"io" "io"
"os" "os"
"os/exec"
path "path/filepath" path "path/filepath"
"regexp" "regexp"
"strings"
) )
var cmdVersion = &Command{ var cmdVersion = &Command{
@ -114,3 +116,16 @@ func getBeegoVersion() string {
} }
return "Beego not installed. Please install it first: https://github.com/astaxie/beego" 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]
}