2015-06-15 13:23



This question already has an answer here:

How can I go build a project in a way that it works for both Mac and Linux (x86 and x64)? Is that even possible?

I searched and found some stuff, but cannot make them work (or maybe I just didn't understood them).

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答


  • dpno17028 dpno17028 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"
    点赞 评论 复制链接分享