]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: permit installing into a subdirectory of $GOPATH/bin
authorIan Lance Taylor <iant@golang.org>
Thu, 30 Jul 2015 22:20:12 +0000 (15:20 -0700)
committerIan Lance Taylor <iant@golang.org>
Fri, 31 Jul 2015 00:37:44 +0000 (00:37 +0000)
In https://golang.org/cl/12080 we forbade installing cross-compiled
binaries into a subdirectory of $GOBIN, in order to fix
https://golang.org/issue/9769.  However, that fix was too aggressive,
in that it also forbade installing into a subdirectory of $GOPATH/bin.

This patch permits installing cross-compiled binaries into a
subdirectory $GOPATH/bin while continuing to forbid installing into a
subdirectory of $GOBIN.

Fixes #11778.

Change-Id: Ibc9919554e8c275beff54ec8bf919cfaa03b11ba
Reviewed-on: https://go-review.googlesource.com/12938
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/pkg.go

index c89543871b8c52778876943e1284e0feec6d65d6..783ae554ba86779188e04dedf5ac0611767de2e7 100644 (file)
@@ -765,7 +765,7 @@ func TestGoInstallErrorOnCrossCompileToBin(t *testing.T) {
        }
        tg.setenv("GOOS", "linux")
        tg.setenv("GOARCH", goarch)
-       tg.runFail("install", "mycmd")
+       tg.run("install", "mycmd")
        tg.setenv("GOBIN", tg.path("."))
        tg.runFail("install", "mycmd")
        tg.run("install", "cmd/pack")
index 98c9594d2e1bd14298af7184f79a3bb90bc470d4..a2c5ba7e5e7c64695a2d051ba8b2f5e5688ef1b4 100644 (file)
@@ -744,8 +744,8 @@ func (p *Package) load(stk *importStack, bp *build.Package, err error) *Package
                } else if p.build.BinDir != "" {
                        // Install to GOBIN or bin of GOPATH entry.
                        p.target = filepath.Join(p.build.BinDir, elem)
-                       if !p.Goroot && strings.Contains(elem, "/") {
-                               // Do not create bin/goos_goarch/elem.
+                       if !p.Goroot && strings.Contains(elem, "/") && gobin != "" {
+                               // Do not create $GOBIN/goos_goarch/elem.
                                p.target = ""
                                p.gobinSubdir = true
                        }