Build Linux GO on Mac

Cross compile go program from Mac, we can use the following command, run from go src folder:

Cross compile go program from Mac, we can use the following command, run from go src folder:

GOOS=linux GOARCH=amd64 CGO_ENABLED=0 ./make.bash — no-clean

But when I install go 1.5.2, and run this command, it report following error:

ERROR: Cannot find /var/root/go1.4/bin/go.
Set $GOROOT_BOOTSTRAP to a working Go tree >= Go 1.4.
./make.bash: line 121: /var/root/go1.4/bin/go: No such file or directory

And I export GOROOT_BOOTSTRAP variable, and it report following error:

go install cmd/dist: open cmd/dist/dist: permission denied

So we need run on root account, and when change to root account, we need to set the GOROOT_BOOTSTRAP again.

export GOROOT_BOOTSTRAP=/usr/local/go
GOOS=linux GOARCH=amd64 CGO_ENABLED=0e ./make.bash — no-clean