From a1fe5bf0109198cd4e5b4ed68ff1c387c8ef20f8 Mon Sep 17 00:00:00 2001 From: Lei Cao Date: Thu, 14 May 2015 15:56:19 +0800 Subject: [PATCH] Using local package name for renamed packages. --- g_docs.go | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/g_docs.go b/g_docs.go index d83ba95..3fbb20f 100644 --- a/g_docs.go +++ b/g_docs.go @@ -149,7 +149,11 @@ func generateDocs(curpath string) { } } for _, im := range f.Imports { - analisyscontrollerPkg(im.Path.Value) + localName := "" + if im.Name != nil { + localName = im.Name.Name + } + analisyscontrollerPkg(localName, im.Path.Value) } for _, d := range f.Decls { switch specDecl := d.(type) { @@ -256,13 +260,17 @@ func analisysNSInclude(baseurl string, ce *ast.CallExpr) string { return cname } -func analisyscontrollerPkg(pkgpath string) { +func analisyscontrollerPkg(localName, pkgpath string) { pkgpath = strings.Trim(pkgpath, "\"") if isSystemPackage(pkgpath) { return } - pps := strings.Split(pkgpath, "/") - importlist[pps[len(pps)-1]] = pkgpath + if localName != "" { + importlist[localName] = pkgpath + } else { + pps := strings.Split(pkgpath, "/") + importlist[pps[len(pps)-1]] = pkgpath + } if pkgpath == "github.com/astaxie/beego" { return }