diff --git a/g_docs.go b/g_docs.go index e5bc0d8..f0152b7 100644 --- a/g_docs.go +++ b/g_docs.go @@ -26,6 +26,7 @@ import ( "path/filepath" "reflect" "regexp" + "runtime" "strconv" "strings" "unicode" @@ -255,6 +256,9 @@ func analisysNSInclude(baseurl string, ce *ast.CallExpr) string { func analisyscontrollerPkg(pkgpath string) { pkgpath = strings.Trim(pkgpath, "\"") + if isSystemPackage(pkgpath) { + return + } pps := strings.Split(pkgpath, "/") importlist[pps[len(pps)-1]] = pkgpath if pkgpath == "github.com/astaxie/beego" { @@ -318,6 +322,18 @@ func analisyscontrollerPkg(pkgpath string) { } } +func isSystemPackage(pkgpath string) bool { + goroot := runtime.GOROOT() + if goroot == "" { + panic("goroot is empty, do you install Go right?") + } + wg, _ := filepath.EvalSymlinks(filepath.Join(goroot, "src", "pkg", pkgpath)) + if utils.FileExists(wg) { + return true + } + return false +} + // parse the func comments func parserComments(comments *ast.CommentGroup, funcName, controllerName, pkgpath string) error { innerapi := swagger.Api{}