mirror of
https://github.com/golang/go
synced 2024-11-18 16:54:43 -07:00
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
|
||||
}
|
||||
fset := token.NewFileSet()
|
||||
for _, file := range buildPkg.GoFiles {
|
||||
f, err := parser.ParseFile(fset, filepath.Join(dir, file), nil, 0)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "could not parse %q: %v\n", file, err)
|
||||
continue
|
||||
}
|
||||
for name := range f.Scope.Objects {
|
||||
if ast.IsExported(name) {
|
||||
exports[name] = true
|
||||
for _, files := range [...][]string{buildPkg.GoFiles, buildPkg.CgoFiles} {
|
||||
for _, file := range files {
|
||||
f, err := parser.ParseFile(fset, filepath.Join(dir, file), nil, 0)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "could not parse %q: %v\n", file, err)
|
||||
continue
|
||||
}
|
||||
for name := range f.Scope.Objects {
|
||||
if ast.IsExported(name) {
|
||||
exports[name] = true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user