1
0
mirror of https://github.com/golang/go synced 2024-11-18 09:04:49 -07:00

cmd/go: initialize in get before loading packages

Otherwise the packages will not pick up the way that -installsuffix is
changed by -buildmode and -race.

Fixes #20512.

Change-Id: Ieca32c958a531beb6331dff30d7e9a4998867dbb
Reviewed-on: https://go-review.googlesource.com/44630
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
This commit is contained in:
Ian Lance Taylor 2017-06-01 17:38:34 -07:00
parent a38c8dfa44
commit 8f9893173b
3 changed files with 19 additions and 2 deletions

View File

@ -3159,6 +3159,20 @@ func TestGoGetUpdate(t *testing.T) {
tg.run("get", "-d", "-u", "github.com/rsc/go-get-issue-9224-cmd")
}
// Issue #20512.
func TestGoGetRace(t *testing.T) {
testenv.MustHaveExternalNetwork(t)
if !canRace {
t.Skip("skipping because race detector not supported")
}
tg := testgo(t)
defer tg.cleanup()
tg.makeTempdir()
tg.setenv("GOPATH", tg.path("."))
tg.run("get", "-race", "github.com/rsc/go-get-issue-9224-cmd")
}
func TestGoGetDomainRoot(t *testing.T) {
// golang.org/issue/9357.
// go get foo.io (not foo.io/subdir) was not working consistently.

View File

@ -90,6 +90,9 @@ func init() {
}
func runGet(cmd *base.Command, args []string) {
work.InstrumentInit()
work.BuildModeInit()
if *getF && !*getU {
base.Fatalf("go get: cannot use -f flag without -u")
}

View File

@ -545,6 +545,8 @@ func libname(args []string, pkgs []*load.Package) (string, error) {
}
func runInstall(cmd *base.Command, args []string) {
InstrumentInit()
BuildModeInit()
InstallPackages(args, false)
}
@ -553,8 +555,6 @@ func InstallPackages(args []string, forGet bool) {
base.Fatalf("cannot install, GOBIN must be an absolute path")
}
InstrumentInit()
BuildModeInit()
pkgs := pkgsFilter(load.PackagesForBuild(args))
for _, p := range pkgs {