]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: special packages must not have any path separators
authorKeith Randall <khr@golang.org>
Fri, 19 Nov 2021 21:28:49 +0000 (13:28 -0800)
committerKeith Randall <khr@golang.org>
Tue, 23 Nov 2021 19:31:05 +0000 (19:31 +0000)
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 <khr@golang.org>
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dan Scales <danscales@google.com>
src/cmd/compile/internal/types/pkg.go

index fe42049ceedfbd462c36f9eef4be4a2fdb294304..0b822a450c9893e669af8d7ed8de93fe99f1c021 100644 (file)
@@ -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