我如何go build
项目以适用于Mac和Linux(x86和x64)的方式?这甚至可能吗?
我搜索并发现了一些东西,但无法使它们起作用(或者我可能只是不理解它们)。
答案 0 :(得分:6)
To build binaries for different platforms, I use GOX
Gox is a simple, no-frills tool for Go cross compilation that behaves a lot like standard go build. Gox will parallelize builds for multiple platforms. Gox will also build the cross-compilation toolchain for you.
You tell it which platforms you want to target, and one command will build a separate binary for each of them. One binary cannot target multiple systems though.
To build for OSX (64 bit) and Linux (32 and 64 bit), you could use:
gox -osarch="darwin/amd64 linux/386 linux/amd64"