Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I build for linux 32-bit with go1.6.2

Is there any combination of GOARCH and GOOS values which I can set in order to build ELF 32-bit binary?

like image 333
duganets Avatar asked May 18 '16 14:05

duganets


People also ask

What Goos Golang?

GOOS refers to the operating system (Linux, Windows, BSD, etc.), while GOARCH refers to the architecture to build for. $ env GOOS=linux GOARCH=arm64 go build -o prepnode_arm64.


1 Answers

GOOS=linux and GOARCH=386.

More examples: architecture:

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

OS:

Windows -> GOOS=windows
Linux   -> GOOS=linux 
OS X    -> GOOS=darwin
FreeBSD -> GOOS=freebsd

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 "

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).

For the current list all supported platforms (GOOS/GOARCH combinations), use the following command:

go tool dist list

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
like image 148
icza Avatar answered Sep 23 '22 12:09

icza