If the linker or compiler is newer than a standard package, go will try to rebuild the
package even if it is outside of the current root (i.e. GOPATH != GOROOT). This is
similar to (or the same as) the problem detailed in issue #3149.
This can be triggered via the following:
$ touch /usr/local/go/pkg/${GOOS}_${GOARCH}/runtime.a
$ touch /usr/local/go/pkg/tool/${GOOS}_${GOARCH}/*
$ export GOPATH=/home/joel/src/mygo
$ go install example/newmath
go install runtime: open /usr/local/go/pkg/openbsd_amd64/runtime.a: permission
denied
Most of the binary distributions avoid this by retaining timestamps, however if this
does not occur (some packaging systems do not do this) it is easily hit due to file
ordering:
$ tar -C /usr/local -zxmf go-1.0.2-linux-amd64.tar.gz
As an aside, even when this is working correctly 'go install -a' still fails since '-a'
includes all packages, not just the ones in the current root.