From 39cc0bc04e109ff0f69e73d567354d9e82b7c24c Mon Sep 17 00:00:00 2001 From: gloomyzerg Date: Fri, 10 Mar 2017 17:49:58 +0800 Subject: [PATCH] fix #332 swagger generate bug on windows --- bee.go | 2 +- util.go | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/bee.go b/bee.go index 690bc07..2c591b8 100644 --- a/bee.go +++ b/bee.go @@ -160,7 +160,7 @@ func main() { // Check if current directory is inside the GOPATH, // if so parse the packages inside it. - if strings.Contains(currentpath, GetGOPATHs()[0]+"/src") && isGenerateDocs(cmd.Name(), args) { + if IsInGOPATH(currentpath) && isGenerateDocs(cmd.Name(), args) { parsePackagesFromDir(currentpath) } diff --git a/util.go b/util.go index 0893144..4a97e6c 100644 --- a/util.go +++ b/util.go @@ -68,6 +68,14 @@ func GetGOPATHs() []string { return paths } +// IsInGOPATH checks the path is in the fisrt GOPATH(/src) or not +func IsInGOPATH(thePath string) bool { + if runtime.GOOS == "windows" { + thePath = filepath.ToSlash(thePath) + } + return strings.Contains(thePath, GetGOPATHs()[0]+"/src") +} + // IsBeegoProject checks whether the current path is a Beego application or not func IsBeegoProject(thePath string) bool { mainFiles := []string{}