Skip to content

Instantly share code, notes, and snippets.

@alekssamos
Forked from zfarbp/arch.md
Created February 24, 2024 10:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alekssamos/58015b9e6320281c63741dcecbfdf19c to your computer and use it in GitHub Desktop.
Save alekssamos/58015b9e6320281c63741dcecbfdf19c to your computer and use it in GitHub Desktop.
Golang - Building Executables for Different Architectures

Golang - Building Executables for Different Architectures

env GOOS=target-OS GOARCH=target-architecture go build package-import-path

# Example
env GOOS=darwin GOARCH=amd64 go build
env GOOS=darwin GOARCH=amd64 go build main.go
env GOOS=darwin GOARCH=amd64 go build github.com/zoo/york/foo/bar

# Raspberry pi
env GOOS=linux GOARCH=arm GOARM=5 go build
GOOS - Target Operating System GOARCH - Target Platform
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
netbsd 386
netbsd amd64
netbsd arm
openbsd 386
openbsd amd64
openbsd arm
plan9 386
plan9 amd64
solaris amd64
windows 386
windows amd64
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment