Closed
Description
If I unpack Go 1.8.3 to a custom location, I either need to set the correct GOROOT
, or it will fail to start.
$ GOROOT=/tmp/go1.8.3 /tmp/go1.8.3/bin/go version
go version go1.8.3 linux/amd64
$ /tmp/go1.8.3/bin/go version
go: cannot find GOROOT directory: /usr/local/go
Go 1.9rc1 does not have this "limitation" any more and even correctly detects its custom GOROOT
:
$ /tmp/go1.9rc1/bin/go version
go version go1.9rc1 linux/amd64
$ /tmp/go1.9rc1/bin/go env
[...]
GOROOT="/tmp/go1.9rc1"
[...]
However, the runtime.GOROOT()
method still defaults to the GOROOT
environmental variable (with the build-path fallback if the env var cannot be found). This is a problem, because it produces runtime issues on systems where Go is not located at the correct path (such as currently Travis).
package main
import (
"fmt"
"runtime"
)
func main() {
fmt.Println(runtime.GOROOT())
}
$ /tmp/go1.9rc1/bin/go run main.go
/usr/local/go