Go交叉编译
Go在1.5版本中改进了对交叉编译的支持,包括统一了编译器、链接器等。从版本1.5开始,对你开发的应用程序进行夸平台交叉编译就变得相当简单了。只需要设置两个环境变量就可以搞定,分别是GOOS
和GOARCH
。
环境变量
- GOOS是你的应用程序将要运行平台的操作系统
- GOARCH是你的应用程序将要运行平台的处理器架构。
有效的$GOOS
和$GOARCH
组合如下:
$GOOS $GOARCH
android arm
darwin 386
darwin amd64
darwin arm
darwin arm64
dragonfly amd64
freebsd 386
freebsd amd64
freebsd arm
linux 386
linux amd64
linux arm
linux arm64
linux ppc64
linux ppc64le
linux mips
linux mipsle
linux mips64
linux mips64le