如何使用go1.6.2为Linux 32位构建

时间:2016-05-18 14:12:41

标签: linux go build elf 32-bit

我是否可以设置GOARCHGOOS值的任意组合以构建ELF 32位二进制文​​件?

1 个答案:

答案 0 :(得分:9)

GOOS=linuxGOARCH=386

更多示例:架构:

32-bit -> GOARCH=386
64-bit -> GOARCH=amd64

OS:

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 "

GOOS + GOARCHsource)的有效组合:

$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