Commit 8f989317 authored by Ian Lance Taylor's avatar Ian Lance Taylor

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: 's avatarRuss Cox <rsc@golang.org>
parent a38c8dfa
......@@ -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.
......
......@@ -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")
}
......
......@@ -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 {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment