mirror of
https://github.com/beego/bee.git
synced 2024-11-21 23:50:54 +00:00
use go env
check project is go mod
or not.
This commit is contained in:
parent
4110083cae
commit
4158ab284e
@ -435,7 +435,7 @@ func analyseControllerPkg(vendorPath, localName, pkgpath string) {
|
|||||||
|
|
||||||
pkgRealpath := ""
|
pkgRealpath := ""
|
||||||
|
|
||||||
if os.Getenv(`GO111MODULE`) == `on` {
|
if bu.IsGOMODULE() {
|
||||||
pkgRealpath = filepath.Join(bu.GetBeeWorkPath(), "..", pkgpath)
|
pkgRealpath = filepath.Join(bu.GetBeeWorkPath(), "..", pkgpath)
|
||||||
} else {
|
} else {
|
||||||
gopaths := bu.GetGOPATHs()
|
gopaths := bu.GetGOPATHs()
|
||||||
|
@ -452,3 +452,14 @@ func GetGoVersionSkipMinor() string {
|
|||||||
strArray := strings.Split(runtime.Version()[2:], `.`)
|
strArray := strings.Split(runtime.Version()[2:], `.`)
|
||||||
return strArray[0] + `.` + strArray[1]
|
return strArray[0] + `.` + strArray[1]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func IsGOMODULE() bool {
|
||||||
|
if combinedOutput, e := exec.Command(`go`, `env`).CombinedOutput(); e != nil {
|
||||||
|
beeLogger.Log.Errorf("i cann't find go.")
|
||||||
|
} else {
|
||||||
|
regex := regexp.MustCompile(`GOMOD="?(.+go.mod)"?`)
|
||||||
|
stringSubmatch := regex.FindStringSubmatch(string(combinedOutput))
|
||||||
|
return len(stringSubmatch) == 2
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user