]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: initialize in get before loading packages
authorIan Lance Taylor <iant@golang.org>
Fri, 2 Jun 2017 00:38:34 +0000 (17:38 -0700)
committerIan Lance Taylor <iant@golang.org>
Tue, 13 Jun 2017 14:45:39 +0000 (14:45 +0000)
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>
src/cmd/go/go_test.go
src/cmd/go/internal/get/get.go
src/cmd/go/internal/work/build.go

index 4a3d4559ed3727d9f5c676460951c61ebab96683..90a95fd23d2dc206a708de51e5ac7c16ff85eac0 100644 (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.
index 0181c5f5b76e0cbc22d1bf343641077a6d222e2a..6291a72fc7e3b09689c2d0c12f5a17601090d30d 100644 (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")
        }
index 77f9fc3e012c0afe9ae081447e184337e9b8d58b..2dfd54171a6d98bd289aa20b6ebcc64f4832f87e 100644 (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 {