Skip to content

Commit

Permalink
go/gcexportdata: use IExportData when writing gcexportdata
Browse files Browse the repository at this point in the history
Updates golang/go#28260

Change-Id: Id0ef98e1599fbef4dd67ba23c20ddb8bc4d33228
Reviewed-on: https://go-review.googlesource.com/c/tools/+/198742
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
  • Loading branch information
stamblerre committed Oct 3, 2019
1 parent c56b4b1 commit fb78014
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion go/gcexportdata/gcexportdata.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func Read(in io.Reader, fset *token.FileSet, imports map[string]*types.Package,
// Write writes encoded type information for the specified package to out.
// The FileSet provides file position information for named objects.
func Write(out io.Writer, fset *token.FileSet, pkg *types.Package) error {
b, err := gcimporter.BExportData(fset, pkg)
b, err := gcimporter.IExportData(fset, pkg)
if err != nil {
return err
}
Expand Down
8 changes: 8 additions & 0 deletions go/internal/gcimporter/iimport.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,20 @@ func IImportData(fset *token.FileSet, imports map[string]*types.Package, data []
p.pkgIndex[pkg] = nameIndex
pkgList[i] = pkg
}
if len(pkgList) == 0 {
errorf("no packages found for %s", path)
panic("unreachable")
}
var localpkg *types.Package
for _, pkg := range pkgList {
if pkg.Path() == path {
localpkg = pkg
break
}
}
if localpkg == nil {
localpkg = pkgList[0]
}

names := make([]string, 0, len(p.pkgIndex[localpkg]))
for name := range p.pkgIndex[localpkg] {
Expand Down

0 comments on commit fb78014

Please sign in to comment.