diff --git a/tools/please_go/ChangeLog b/tools/please_go/ChangeLog index 1ea9c35..9206817 100644 --- a/tools/please_go/ChangeLog +++ b/tools/please_go/ChangeLog @@ -1,3 +1,7 @@ +Version 1.10.6 +-------------- + * packageinfo files correctly account for stdlib vendoring + Version 1.10.5 -------------- * upgrade x/mod to support new directives diff --git a/tools/please_go/VERSION b/tools/please_go/VERSION index db77e0e..7b4d9a4 100644 --- a/tools/please_go/VERSION +++ b/tools/please_go/VERSION @@ -1 +1 @@ -1.10.5 +1.10.6 diff --git a/tools/please_go/packageinfo/packageinfo.go b/tools/please_go/packageinfo/packageinfo.go index ebc2162..8e547ac 100644 --- a/tools/please_go/packageinfo/packageinfo.go +++ b/tools/please_go/packageinfo/packageinfo.go @@ -88,6 +88,20 @@ func WritePackageInfo(importPath string, srcRoot, importconfig string, imports m return !present }) } + // Vendor packages. They aren't identified by the original imports but we know what they are now. + vendorised := map[string]*packages.Package{} + for _, pkg := range pkgs { + if strings.HasPrefix(pkg.PkgPath, "vendor/") { + vendorised[strings.TrimPrefix(pkg.PkgPath, "vendor/")] = pkg + } + } + for _, pkg := range pkgs { + for k := range pkg.Imports { + if v, present := vendorised[k]; present { + pkg.Imports[k] = v + } + } + } // Ensure output is deterministic sort.Slice(pkgs, func(i, j int) bool { return pkgs[i].ID < pkgs[j].ID