go.tools/imports: recognize exports in cgo files
Fixes golang/go#8815. LGTM=bradfitz R=bradfitz CC=golang-codereviews https://golang.org/cl/143660044
This commit is contained in:
parent
e62e5f9885
commit
b6c30b58fc
|
@ -283,15 +283,17 @@ func loadExportsGoPath(dir string) map[string]bool {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
fset := token.NewFileSet()
|
fset := token.NewFileSet()
|
||||||
for _, file := range buildPkg.GoFiles {
|
for _, files := range [...][]string{buildPkg.GoFiles, buildPkg.CgoFiles} {
|
||||||
f, err := parser.ParseFile(fset, filepath.Join(dir, file), nil, 0)
|
for _, file := range files {
|
||||||
if err != nil {
|
f, err := parser.ParseFile(fset, filepath.Join(dir, file), nil, 0)
|
||||||
fmt.Fprintf(os.Stderr, "could not parse %q: %v\n", file, err)
|
if err != nil {
|
||||||
continue
|
fmt.Fprintf(os.Stderr, "could not parse %q: %v\n", file, err)
|
||||||
}
|
continue
|
||||||
for name := range f.Scope.Objects {
|
}
|
||||||
if ast.IsExported(name) {
|
for name := range f.Scope.Objects {
|
||||||
exports[name] = true
|
if ast.IsExported(name) {
|
||||||
|
exports[name] = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue