Skip to content

Instantly share code, notes, and snippets.

@sougou
Created April 9, 2017 02:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sougou/2255bc77bf8eaa45eadcc44f8832514f to your computer and use it in GitHub Desktop.
Save sougou/2255bc77bf8eaa45eadcc44f8832514f to your computer and use it in GitHub Desktop.
diff --git a/imports/fix.go b/imports/fix.go
index 1387c997..3504d40b 100644
--- a/imports/fix.go
+++ b/imports/fix.go
@@ -641,12 +641,6 @@ func loadExportsGoPath(expectPackage, dir string) map[string]bool {
// handled by ctx.MatchFile.
continue
}
- if pkgName != expectPackage {
- if Debug {
- log.Printf("scan of dir %v is not expected package %v (actually %v)", dir, expectPackage, pkgName)
- }
- return nil
- }
for name := range f.Scope.Objects {
if ast.IsExported(name) {
exports[name] = true
@@ -727,7 +721,11 @@ func findImportGoPath(pkgName string, symbols map[string]bool, filename string)
// Find candidate packages, looking only at their directory names first.
var candidates []*pkg
for _, pkg := range dirScan {
- if pkgIsCandidate(filename, pkgName, pkg) {
+ name := pkgName
+ if strings.HasSuffix(name, "pb") {
+ name = name[:len(name)-2]
+ }
+ if pkgIsCandidate(filename, name, pkg) {
candidates = append(candidates, pkg)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment