Skip to content

Instantly share code, notes, and snippets.

@slv922
Last active December 20, 2017 11:25
Show Gist options
  • Save slv922/d47853e241b8505a36d6a870ca265aef to your computer and use it in GitHub Desktop.
Save slv922/d47853e241b8505a36d6a870ca265aef to your computer and use it in GitHub Desktop.
Golang Cross-compile
# 编译到 linux 64bit
$ GOOS=linux GOARCH=amd64 go build
# 或者可以使用 -o 选项指定生成二进制文件名字
$ GOOS=linux GOARCH=amd64 go build -o app.linux
# 编译到 linux 32bit
$ GOOS=linux GOARCH=386 go build
# 编译到 windows 64bit
$ GOOS=windows GOARCH=amd64 go build
# 编译到 windows 32bit
$ GOOS=windows GOARCH=386 go build
# 编译到 Mac OS X 64bit
$ GOOS=darwin GOARCH=amd64 go build
Ref: http://dmdgeeker.com/goBook/docs/ch01/cross_compile.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment