Check Gopath in one place

This commit is contained in:
astaxie 2017-04-24 20:51:56 +08:00
parent 3daa0d2639
commit 6afbafa250
1 changed files with 3 additions and 3 deletions

View File

@ -17,6 +17,7 @@ import (
"github.com/beego/bee/cmd/commands" "github.com/beego/bee/cmd/commands"
beeLogger "github.com/beego/bee/logger" beeLogger "github.com/beego/bee/logger"
"github.com/beego/bee/logger/colors" "github.com/beego/bee/logger/colors"
"github.com/beego/bee/utils"
"gopkg.in/yaml.v2" "gopkg.in/yaml.v2"
) )
@ -117,16 +118,15 @@ func ShowShortVersionBanner() {
} }
func GetBeegoVersion() string { func GetBeegoVersion() string {
gopath := os.Getenv("GOPATH")
re, err := regexp.Compile(`VERSION = "([0-9.]+)"`) re, err := regexp.Compile(`VERSION = "([0-9.]+)"`)
if err != nil { if err != nil {
return "" return ""
} }
if gopath == "" { wgopath := utils.GetGOPATHs()
if len(wgopath) == 0 {
beeLogger.Log.Error("You need to set GOPATH environment variable") beeLogger.Log.Error("You need to set GOPATH environment variable")
return "" return ""
} }
wgopath := path.SplitList(gopath)
for _, wg := range wgopath { for _, wg := range wgopath {
wg, _ = path.EvalSymlinks(path.Join(wg, "src", "github.com", "astaxie", "beego")) wg, _ = path.EvalSymlinks(path.Join(wg, "src", "github.com", "astaxie", "beego"))
filename := path.Join(wg, "beego.go") filename := path.Join(wg, "beego.go")