1
0
mirror of https://github.com/beego/bee.git synced 2024-06-17 10:33:33 +00:00
Consider vendor folder when analyzing router.go parsed imports.
This commit is contained in:
Gero Nimo 2017-03-31 20:25:50 -03:00
parent abf3c41032
commit 12a23c9cf5

View File

@ -194,7 +194,7 @@ func GenerateDocs(curpath string) {
if im.Name != nil { if im.Name != nil {
localName = im.Name.Name localName = im.Name.Name
} }
analyseControllerPkg(localName, im.Path.Value) analyseControllerPkg(path.Join(curpath, "vendor"), localName, im.Path.Value)
} }
for _, d := range f.Decls { for _, d := range f.Decls {
switch specDecl := d.(type) { switch specDecl := d.(type) {
@ -336,7 +336,7 @@ func analyseNSInclude(baseurl string, ce *ast.CallExpr) string {
return cname return cname
} }
func analyseControllerPkg(localName, pkgpath string) { func analyseControllerPkg(vendorPath, localName, pkgpath string) {
pkgpath = strings.Trim(pkgpath, "\"") pkgpath = strings.Trim(pkgpath, "\"")
if isSystemPackage(pkgpath) { if isSystemPackage(pkgpath) {
return return
@ -356,12 +356,19 @@ func analyseControllerPkg(localName, pkgpath string) {
} }
pkgRealpath := "" pkgRealpath := ""
wgopath := filepath.SplitList(gopath) wg, _ := filepath.EvalSymlinks(filepath.Join(vendorPath, pkgpath))
for _, wg := range wgopath { if utils.FileExists(wg) {
wg, _ = filepath.EvalSymlinks(filepath.Join(wg, "src", pkgpath)) pkgRealpath = wg
if utils.FileExists(wg) { } else {
pkgRealpath = wg wgopath := filepath.SplitList(gopath)
break for _, wg := range wgopath {
beeLogger.Log.Infof("wg := range wgopath => %s", wg)
beeLogger.Log.Infof("filepath.EvalSymlinks => %s", filepath.Join(wg, "src", pkgpath))
wg, _ = filepath.EvalSymlinks(filepath.Join(wg, "src", pkgpath))
if utils.FileExists(wg) {
pkgRealpath = wg
break
}
} }
} }
if pkgRealpath != "" { if pkgRealpath != "" {
@ -370,7 +377,7 @@ func analyseControllerPkg(localName, pkgpath string) {
} }
pkgCache[pkgpath] = struct{}{} pkgCache[pkgpath] = struct{}{}
} else { } else {
beeLogger.Log.Fatalf("Package '%s' does not exist in the GOPATH", pkgpath) beeLogger.Log.Fatalf("Package '%s' does not exist in the GOPATH or vendor path", pkgpath)
} }
fileSet := token.NewFileSet() fileSet := token.NewFileSet()