From d0ca3933b724e6be513276cc2edb34e10d667438 Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Sat, 1 Dec 2018 00:13:28 +0000 Subject: [PATCH] cmd/bundle: change the behavior of the -underscore flag It used to rewrite golang.org/x/* imports to golang_org/x/*. But https://golang.org/cl/147443 renamed golang_org/x to internal/x, which broke the ability to run "go generate" in net/http, which runs this command. Given that net/http (and Go itself) is the only caller of cmd/bundle or the -underscore flag, repurpose it to instead rewrite the golang.org/x imports to internal/x, like CL 147443. But we keep its name out of laziness and to minimize the number of cross-repo changes needed. Change-Id: I310ce8b45812a26c8b3522eaf407fffff138b1be Reviewed-on: https://go-review.googlesource.com/c/152097 Run-TryBot: Brad Fitzpatrick Run-TryBot: Bryan C. Mills TryBot-Result: Gobot Gobot Reviewed-by: Bryan C. Mills --- cmd/bundle/main.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/bundle/main.go b/cmd/bundle/main.go index 7c552683..7e95d583 100644 --- a/cmd/bundle/main.go +++ b/cmd/bundle/main.go @@ -106,7 +106,7 @@ var ( dstPath = flag.String("dst", "", "set destination import `path` (default taken from current directory)") pkgName = flag.String("pkg", "", "set destination package `name` (default taken from current directory)") prefix = flag.String("prefix", "&_", "set bundled identifier prefix to `p` (default is \"&_\", where & stands for the original name)") - underscore = flag.Bool("underscore", false, "rewrite golang.org to golang_org in imports; temporary workaround for golang.org/issue/16333") + underscore = flag.Bool("underscore", false, "rewrite golang.org/x/* to internal/x/* imports; temporary workaround for golang.org/issue/16333") importMap = map[string]string{} ) @@ -298,7 +298,7 @@ func bundle(src, dst, dstpkg, prefix string) ([]byte, error) { pkgStd[spec] = true } else { if *underscore { - spec = strings.Replace(spec, "golang.org/", "golang_org/", 1) + spec = strings.Replace(spec, "golang.org/x/", "internal/x/", 1) } pkgExt[spec] = true }