diff options
author | Hajime Hoshi <hajimehoshi@gmail.com> | 2020-12-26 02:25:13 +0900 |
---|---|---|
committer | Hajime Hoshi <hajimehoshi@gmail.com> | 2021-04-12 15:17:33 +0000 |
commit | 117b1c84d3678a586c168a5f7f2f0a750c27f0c2 (patch) | |
tree | 767c0b7afe9d4ea029802dbb864d5f4f4b06213f /src/cmd/go/internal/load/pkg.go | |
parent | c26f954a540a99eafac6ee3bb3b996c750aad8a4 (diff) | |
download | go-117b1c84d3678a586c168a5f7f2f0a750c27f0c2.tar.gz go-117b1c84d3678a586c168a5f7f2f0a750c27f0c2.zip |
cmd/go/internal/work: remove '_test' from import paths in stacktraces when -trimpath is specified
ExampleFrames with -trimpath failed since the content of Frame's File
changed when -trimpath is specified.
This CL fixes the issue by adding a new field OrigImportPath to
PackageInternal, which represents the original import path before adding
'_test' suffix for an external test package, and always using it to
create paths for the build tools.
Fixes golang/go#43380
Change-Id: Ibbc947eb3ae08a7ba81f13f03af67c8745b5c69f
Reviewed-on: https://go-review.googlesource.com/c/go/+/279440
Run-TryBot: Hajime Hoshi <hajimehoshi@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Hajime Hoshi <hajimehoshi@gmail.com>
Reviewed-by: Jay Conrod <jayconrod@google.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Diffstat (limited to 'src/cmd/go/internal/load/pkg.go')
-rw-r--r-- | src/cmd/go/internal/load/pkg.go | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/cmd/go/internal/load/pkg.go b/src/cmd/go/internal/load/pkg.go index a6d730d0d8..00c50bf38f 100644 --- a/src/cmd/go/internal/load/pkg.go +++ b/src/cmd/go/internal/load/pkg.go @@ -207,6 +207,7 @@ type PackageInternal struct { BuildInfo string // add this info to package main TestmainGo *[]byte // content for _testmain.go Embed map[string][]string // //go:embed comment mapping + OrigImportPath string // original import path before adding '_test' suffix Asmflags []string // -asmflags for this package Gcflags []string // -gcflags for this package @@ -402,6 +403,7 @@ func (p *Package) copyBuild(pp *build.Package) { p.EmbedPatterns = pp.EmbedPatterns p.TestEmbedPatterns = pp.TestEmbedPatterns p.XTestEmbedPatterns = pp.XTestEmbedPatterns + p.Internal.OrigImportPath = pp.ImportPath } // A PackageError describes an error loading information about a package. |