diff options
Diffstat (limited to 'src/cmd/go/pkg.go')
-rw-r--r-- | src/cmd/go/pkg.go | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/cmd/go/pkg.go b/src/cmd/go/pkg.go index 852a1a0db9..d69fa5118f 100644 --- a/src/cmd/go/pkg.go +++ b/src/cmd/go/pkg.go @@ -178,7 +178,9 @@ func (p *Package) copyBuild(pp *build.Package) { p.CgoCXXFLAGS = pp.CgoCXXFLAGS p.CgoLDFLAGS = pp.CgoLDFLAGS p.CgoPkgConfig = pp.CgoPkgConfig - p.Imports = pp.Imports + // We modify p.Imports in place, so make copy now. + p.Imports = make([]string, len(pp.Imports)) + copy(p.Imports, pp.Imports) p.TestGoFiles = pp.TestGoFiles p.TestImports = pp.TestImports p.XTestGoFiles = pp.XTestGoFiles @@ -953,6 +955,10 @@ func (p *Package) load(stk *importStack, bp *build.Package, err error) *Package if p.Name == "main" && goarch == "arm" { importPaths = append(importPaths, "math") } + // In coverage atomic mode everything depends on sync/atomic. + if testCoverMode == "atomic" && (!p.Standard || (p.ImportPath != "runtime/cgo" && p.ImportPath != "runtime/race" && p.ImportPath != "sync/atomic")) { + importPaths = append(importPaths, "sync/atomic") + } } // Runtime and its internal packages depend on runtime/internal/sys, |