diff --git a/imports/fix.go b/imports/fix.go index c77f93ff..47a98f9d 100644 --- a/imports/fix.go +++ b/imports/fix.go @@ -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 + } } } }