1
0
mirror of https://github.com/beego/bee.git synced 2024-11-25 20:10:55 +00:00

Merge pull request #391 from beego/develop

Develop
This commit is contained in:
astaxie 2017-03-24 22:35:48 +08:00 committed by GitHub
commit bef9d4d5e8
2 changed files with 8 additions and 4 deletions

View File

@ -17,7 +17,6 @@ import (
"flag" "flag"
"log" "log"
"os" "os"
"strings"
"github.com/beego/bee/cmd" "github.com/beego/bee/cmd"
"github.com/beego/bee/cmd/commands" "github.com/beego/bee/cmd/commands"
@ -64,7 +63,7 @@ func main() {
// Check if current directory is inside the GOPATH, // Check if current directory is inside the GOPATH,
// if so parse the packages inside it. // if so parse the packages inside it.
if strings.Contains(currentpath, utils.GetGOPATHs()[0]+"/src") && cmd.IfGenerateDocs(c.Name(), args) { if utils.IsInGOPATH(currentpath) && cmd.IfGenerateDocs(c.Name(), args) {
swaggergen.ParsePackagesFromDir(currentpath) swaggergen.ParsePackagesFromDir(currentpath)
} }

View File

@ -61,12 +61,17 @@ func GetGOPATHs() []string {
return paths return paths
} }
// IsInGOPATH checks the path is in the fisrt GOPATH(/src) or not // IsInGOPATH checks whether the path is inside of any GOPATH or not
func IsInGOPATH(thePath string) bool { func IsInGOPATH(thePath string) bool {
if runtime.GOOS == "windows" { if runtime.GOOS == "windows" {
thePath = filepath.ToSlash(thePath) thePath = filepath.ToSlash(thePath)
} }
return strings.Contains(thePath, GetGOPATHs()[0]+"/src") for _, gopath := range GetGOPATHs() {
if strings.Contains(thePath, gopath + "/src") {
return true
}
}
return false
} }
// IsBeegoProject checks whether the current path is a Beego application or not // IsBeegoProject checks whether the current path is a Beego application or not