From: Keith Randall Date: Fri, 19 Nov 2021 21:28:49 +0000 (-0800) Subject: cmd/compile: special packages must not have any path separators X-Git-Tag: go1.18beta1~200 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=0f64c21d90c7017df4f199a5852d60d4b474c03c;p=gostls13.git cmd/compile: special packages must not have any path separators We want to distinguish special compiler-generated package paths, like go.shape, from user paths, like go.opentelemetry.io/otel/semconv. The former have no slash in them. Writing a test for this seems hard, as the dependency we'd need to add would be non-hermetic. (Or it would need a new tricky run.go mode.) This CL does fix the example in the issue. Fixes #49606 Change-Id: I38f1b970b6dd31e0617763a27ff227e3afee74d5 Reviewed-on: https://go-review.googlesource.com/c/go/+/365834 Trust: Keith Randall Trust: Dan Scales Run-TryBot: Keith Randall TryBot-Result: Go Bot Reviewed-by: Dan Scales --- diff --git a/src/cmd/compile/internal/types/pkg.go b/src/cmd/compile/internal/types/pkg.go index fe42049cee..0b822a450c 100644 --- a/src/cmd/compile/internal/types/pkg.go +++ b/src/cmd/compile/internal/types/pkg.go @@ -49,7 +49,7 @@ func NewPkg(path, name string) *Pkg { p := new(Pkg) p.Path = path p.Name = name - if strings.HasPrefix(path, "go.") { + if strings.HasPrefix(path, "go.") && !strings.Contains(path, "/") { // Special compiler-internal packages don't need to be escaped. // This particularly helps with the go.shape package. p.Prefix = path