This is a creation in Article, where the information may have evolved or changed.
The local development environment is OS X server is Linux, so need to compile Linux go program, the method is as follows:
GOOS and Goarch reference for each platform
OS ARCH os Versionv
Linux 386/amd64/arm >= Linux 2.6
Darwin 386/amd64 OS X (Snow Leopard + Lion)
FreeBSD 386/amd64 >= FreeBSD 7
Windows 386/AMD64 >= Windows 2000
$ cd /usr/local/go/src$ sudo CGO_ENABLED=0 GOOS=linux GOARCH=amd64 ./make.bash
This is not to recompile go, because when you install go, you just compile what your local system needs, and cross-platform compilation requires more support for other platforms in go. So, there is./make.bash such a process.
The execution results are similar to the following:
sudo CGO_ENABLED=0 GOOS=linux GOARCH=amd64 ./make.bashPassword:Building C bootstrap tool.cmd/distBuilding compilers and Go bootstrap tool for host, darwin/amd64.lib9libbiolibmachmisc/pprofcmd/addr2linecmd/covcmd/nmcmd/objdumpcmd/packcmd/profcmd/cc……pkg/text/template/parsepkg/text/templatepkg/go/docpkg/go/buildcmd/gopkg/runtime (linux/amd64)Building packages and commands for host, darwin/amd64.runtimeerrorssync/atomicunicodeunicode/utf8mathsyncunicode/utf16crypto/subtleiosyscall……….net/rpc/jsonrpctesting/iotesttesting/quickBuilding packages and commands for linux/amd64.runtimeerrorssync/atomicunicodeunicode/utf8mathsyncunicode/utf16……..testingnet/rpc/jsonrpctesting/iotesttesting/quickInstalled Go for linux/amd64 in /usr/local/goInstalled commands in /usr/local/go/bin
To the source code directory to execute:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build sina.go
Go build without the preceding parameters simply compiles the executable file that the development environment applies to.