diff -r a3c0a11b128a AUTHORS --- a/AUTHORS Sun Feb 24 21:57:16 2013 -0800 +++ b/AUTHORS Mon Feb 25 12:54:54 2013 +0100 @@ -105,6 +105,7 @@ Francisco Souza Frithjof Schulze Gary Burd +Geert-Johan Riemer Georg Reinke Gideon Jan-Wessel Redelinghuys Giles Lean diff -r a3c0a11b128a CONTRIBUTORS --- a/CONTRIBUTORS Sun Feb 24 21:57:16 2013 -0800 +++ b/CONTRIBUTORS Mon Feb 25 12:54:54 2013 +0100 @@ -165,6 +165,7 @@ Fumitoshi Ukai Gaal Yahas Gary Burd +Geert-Johan Riemer Georg Reinke Gideon Jan-Wessel Redelinghuys Giles Lean diff -r a3c0a11b128a src/cmd/go/build.go --- a/src/cmd/go/build.go Sun Feb 24 21:57:16 2013 -0800 +++ b/src/cmd/go/build.go Mon Feb 25 12:54:54 2013 +0100 @@ -308,6 +308,7 @@ goos string archChar string exeSuffix string + gobin string ) func init() { @@ -321,6 +322,7 @@ if err != nil { fatalf("%s", err) } + gobin = buildContext.GOBIN } // A builder holds global state about a build. @@ -382,7 +384,6 @@ var ( goroot = filepath.Clean(runtime.GOROOT()) - gobin = os.Getenv("GOBIN") gorootBin = filepath.Join(goroot, "bin") gorootSrcPkg = filepath.Join(goroot, "src/pkg") gorootPkg = filepath.Join(goroot, "pkg") diff -r a3c0a11b128a src/cmd/go/pkg.go --- a/src/cmd/go/pkg.go Sun Feb 24 21:57:16 2013 -0800 +++ b/src/cmd/go/pkg.go Mon Feb 25 12:54:54 2013 +0100 @@ -233,9 +233,6 @@ // See issue 3268 for mistakes to avoid. bp, err := buildContext.Import(path, srcDir, 0) bp.ImportPath = importPath - if gobin != "" { - bp.BinDir = gobin - } p.load(stk, bp, err) if p.Error != nil && len(importPos) > 0 { pos := importPos[0] diff -r a3c0a11b128a src/pkg/go/build/build.go --- a/src/pkg/go/build/build.go Sun Feb 24 21:57:16 2013 -0800 +++ b/src/pkg/go/build/build.go Mon Feb 25 12:54:54 2013 +0100 @@ -30,6 +30,7 @@ GOARCH string // target architecture GOOS string // target operating system GOROOT string // Go root + GOBIN string // Go bin GOPATH string // Go path CgoEnabled bool // whether cgo can be used BuildTags []string // additional tags to recognize in +build lines @@ -264,6 +265,7 @@ c.GOARCH = envOr("GOARCH", runtime.GOARCH) c.GOOS = envOr("GOOS", runtime.GOOS) c.GOROOT = runtime.GOROOT() + c.GOBIN = envOr("GOBIN", "") c.GOPATH = envOr("GOPATH", "") c.Compiler = runtime.Compiler @@ -518,7 +520,11 @@ p.SrcRoot = ctxt.joinPath(p.Root, "src") } p.PkgRoot = ctxt.joinPath(p.Root, "pkg") - p.BinDir = ctxt.joinPath(p.Root, "bin") + if ctxt.GOBIN != "" { + p.BinDir = ctxt.GOBIN + } else { + p.BinDir = ctxt.joinPath(p.Root, "bin") + } if pkga != "" { p.PkgObj = ctxt.joinPath(p.Root, pkga) }