From 92294ec639643f32358daa4bf8f7f90a9c8e6617 Mon Sep 17 00:00:00 2001 From: Peter Ebden Date: Wed, 13 Mar 2024 15:05:46 +0000 Subject: [PATCH 1/2] Handle vendor packages --- tools/please_go/packageinfo/packageinfo.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) 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 From 864d05d69e4e9e9517da3dc0fb2bead3cff763e5 Mon Sep 17 00:00:00 2001 From: Peter Ebden Date: Wed, 13 Mar 2024 15:12:43 +0000 Subject: [PATCH 2/2] version --- tools/please_go/ChangeLog | 4 ++++ tools/please_go/VERSION | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) 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