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

cmd/go: don't accept a relative path as GOBIN

Fixes #12907.

Change-Id: I5925852fe6962d4ec7dbb3ea5323e8ddfaf9d576
Reviewed-on: https://go-review.googlesource.com/15755
Reviewed-by: Andrew Gerrand <adg@golang.org>
Run-TryBot: Andrew Gerrand <adg@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
Burcu Dogan 2015-10-12 08:56:05 -07:00 committed by Andrew Gerrand
parent c6ef16b60a
commit 5b9c6b9e9e
4 changed files with 15 additions and 2 deletions

View File

@ -886,7 +886,7 @@ DIR/bin/quux, not DIR/bin/foo/quux. The "foo/" prefix is stripped
so that you can add DIR/bin to your PATH to get at the
installed commands. If the GOBIN environment variable is
set, commands are installed to the directory it names instead
of DIR/bin.
of DIR/bin. GOBIN must be an absolute path.
Here's an example directory layout:

View File

@ -501,6 +501,10 @@ func libname(args []string) string {
}
func runInstall(cmd *Command, args []string) {
if gobin != "" && !filepath.IsAbs(gobin) {
fatalf("cannot install, GOBIN must be an absolute path")
}
raceInit()
buildModeInit()
pkgs := pkgsFilter(packagesForBuild(args))

View File

@ -1145,6 +1145,15 @@ func TestInstallFailsWithNoBuildableFiles(t *testing.T) {
tg.grepStderr("no buildable Go source files", "go install cgotest did not report 'no buildable Go Source files'")
}
func TestRelativeGOBINFail(t *testing.T) {
tg := testgo(t)
defer tg.cleanup()
tg.tempFile("triv.go", `package main; func main() {}`)
tg.setenv("GOBIN", ".")
tg.runFail("install")
tg.grepStderr("cannot install, GOBIN must be an absolute path", "go install must fail if $GOBIN is a relative path")
}
// Test that without $GOBIN set, binaries get installed
// into the GOPATH bin directory.
func TestInstallIntoGOPATH(t *testing.T) {

View File

@ -307,7 +307,7 @@ DIR/bin/quux, not DIR/bin/foo/quux. The "foo/" prefix is stripped
so that you can add DIR/bin to your PATH to get at the
installed commands. If the GOBIN environment variable is
set, commands are installed to the directory it names instead
of DIR/bin.
of DIR/bin. GOBIN must be an absolute path.
Here's an example directory layout: