1
0
mirror of https://github.com/beego/bee.git synced 2025-07-04 11:40:17 +00:00

add parms for go executable file path!

This commit is contained in:
qiantao
2019-03-05 19:24:29 +08:00
parent 10bb0454f6
commit f1826c0bc3
5 changed files with 22 additions and 14 deletions

View File

@ -48,7 +48,7 @@ const shortVersionBanner = `______
`
var CmdVersion = &commands.Command{
UsageLine: "version",
UsageLine: "version [-gobin=go] [-o=json] ",
Short: "Prints the current Bee version",
Long: `
Prints the current Bee, Beego and Go version alongside the platform information.
@ -59,9 +59,12 @@ var outputFormat string
const version = "1.10.0"
var cmdName = "go"
func init() {
fs := flag.NewFlagSet("version", flag.ContinueOnError)
fs.StringVar(&outputFormat, "o", "", "Set the output format. Either json or yaml.")
fs.StringVar(&cmdName, "gobin", "go", "go executable file path or alias")
CmdVersion.Flag = *fs
commands.AvailableCommands = append(commands.AvailableCommands, CmdVersion)
}
@ -168,7 +171,7 @@ func GetGoVersion() string {
err error
)
if cmdOut, err = exec.Command("go", "version").Output(); err != nil {
if cmdOut, err = exec.Command(cmdName, "version").Output(); err != nil {
beeLogger.Log.Fatalf("There was an error running 'go version' command: %s", err)
}
return strings.Split(string(cmdOut), " ")[2]