如何使用 go1.6.2 为 linux 32 位构建 [英] How can I build for linux 32-bit with go1.6.2
问题描述
是否可以设置 GOARCH
和 GOOS
值的任何组合以构建 ELF 32 位二进制文件?
Is there any combination of GOARCH
and GOOS
values which I can set in order to build ELF 32-bit binary?
推荐答案
GOOS=linux
和 GOARCH=386
.
更多示例:架构:
32-bit -> GOARCH=386
64-bit -> GOARCH=amd64
操作系统:
Windows -> GOOS=windows
Linux -> GOOS=linux
OS X -> GOOS=darwin
FreeBSD -> GOOS=freebsd
有关完整列表(有效的单个"值),请参阅 go/build/syslist.go
文件:
For the complete list (valid "individual" values) refer to go/build/syslist.go
file:
const goosList = "android darwin dragonfly freebsd linux nacl netbsd openbsd plan9 solaris windows "
const goarchList = "386 amd64 amd64p32 arm armbe arm64 arm64be ppc64 ppc64le mips mipsle mips64 mips64le mips64p32 mips64p32le ppc s390 s390x sparc sparc64 "
请注意,上面的列表是一个不断增长的列表,不再支持的平台不会被删除(因为该列表用于 go/build 文件名匹配).
Note that the above list is an ever-growing list, platforms not supported anymore are not removed (as that list is used for go/build filename matching).
对于当前所有支持平台(GOOS/GOARCH 组合)的列表,使用以下命令:
For the current list all supported platforms (GOOS/GOARCH combinations), use the following command:
go tool dist list
GOOS
+ GOARCH
的有效组合(来源):
The valid combinations of GOOS
+ GOARCH
(source):
$GOOS $GOARCH
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 mips64
linux mips64le
netbsd 386
netbsd amd64
netbsd arm
openbsd 386
openbsd amd64
openbsd arm
plan9 386
plan9 amd64
solaris amd64
windows 386
windows amd64
这篇关于如何使用 go1.6.2 为 linux 32 位构建的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!