【发布时间】:2016-09-15 02:14:44
【问题描述】:
为了构建 ELF 32 位二进制文件,我可以设置 GOARCH 和 GOOS 值的任何组合吗?
【问题讨论】:
-
GOOS=linux和GOARCH=386。 -
谢谢,env arg 名称拼写错误导致二进制错误:(
为了构建 ELF 32 位二进制文件,我可以设置 GOARCH 和 GOOS 值的任何组合吗?
【问题讨论】:
GOOS=linux 和 GOARCH=386。
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 文件:
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 文件名匹配)。
对于当前所有支持的平台列表(GOOS/GOARCH 组合),使用以下命令:
go tool dist list
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
【讨论】: