This is a creation in Article, where the information may have evolved or changed.
http://spf13.com/post/cross-compiling-go/
Https://coderwall.com/p/pnfwxg/cross-compiling-golang
Installation settings
Reference: HTTP://STACKOVERFLOW.COM/QUESTIONS/12168873/CROSS-COMPILE-GO-ON-OSX
You can go to the Go src directory and execute the command (the target system is 32bit windows for example):
cd /usr/local/go/srcsudo GOOS=windows GOARCH=386 CGO_ENABLED=0 ./make.bash --no-clean
If you have a Mac, you can use homebrew to install it directly:
# Linux, Darwin, and Windows# All the cross-compilers
If you have already installed go, you can switch reinstall
to a command to reinstall it.
Compile
Set Environment variables:
Goarch-the architecture, e.g AMD64, 386 or arm
Goos-the operating System-linux, Darwin or Windows
Example:
$ GOARCH=arm GOOS=linux go build helloworld