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:
Josh Bleecher Snyder 2014-09-29 12:46:11 -07:00 committed by Brad Fitzpatrick
parent e62e5f9885
commit b6c30b58fc
1 changed files with 11 additions and 9 deletions

View File

@ -283,7 +283,8 @@ 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} {
for _, file := range files {
f, err := parser.ParseFile(fset, filepath.Join(dir, file), nil, 0) f, err := parser.ParseFile(fset, filepath.Join(dir, file), nil, 0)
if err != nil { if err != nil {
fmt.Fprintf(os.Stderr, "could not parse %q: %v\n", file, err) fmt.Fprintf(os.Stderr, "could not parse %q: %v\n", file, err)
@ -295,6 +296,7 @@ func loadExportsGoPath(dir string) map[string]bool {
} }
} }
} }
}
return exports return exports
} }