README.md
1# Gox - Simple Go Cross Compilation
2
3Gox is a simple, no-frills tool for Go cross compilation that behaves a
4lot like standard `go build`. Gox will parallelize builds for multiple
5platforms. Gox will also build the cross-compilation toolchain for you.
6
7## Installation
8
9To install Gox, please use `go get`. We tag versions so feel free to
10checkout that tag and compile.
11
12```
13$ go get github.com/mitchellh/gox
14...
15$ gox -h
16...
17```
18
19## Usage
20
21If you know how to use `go build`, then you know how to use Gox. For
22example, to build the current package, specify no parameters and just
23call `gox`. Gox will parallelize based on the number of CPUs you have
24by default and build for every platform by default:
25
26```
27$ gox
28Number of parallel builds: 4
29
30--> darwin/386: github.com/mitchellh/gox
31--> darwin/amd64: github.com/mitchellh/gox
32--> linux/386: github.com/mitchellh/gox
33--> linux/amd64: github.com/mitchellh/gox
34--> linux/arm: github.com/mitchellh/gox
35--> freebsd/386: github.com/mitchellh/gox
36--> freebsd/amd64: github.com/mitchellh/gox
37--> openbsd/386: github.com/mitchellh/gox
38--> openbsd/amd64: github.com/mitchellh/gox
39--> windows/386: github.com/mitchellh/gox
40--> windows/amd64: github.com/mitchellh/gox
41--> freebsd/arm: github.com/mitchellh/gox
42--> netbsd/386: github.com/mitchellh/gox
43--> netbsd/amd64: github.com/mitchellh/gox
44--> netbsd/arm: github.com/mitchellh/gox
45--> plan9/386: github.com/mitchellh/gox
46```
47
48Or, if you want to build a package and sub-packages:
49
50```
51$ gox ./...
52...
53```
54
55Or, if you want to build multiple distinct packages:
56
57```
58$ gox github.com/mitchellh/gox github.com/hashicorp/serf
59...
60```
61
62Or if you want to just build for linux:
63
64```
65$ gox -os="linux"
66...
67```
68
69Or maybe you just want to build for 64-bit linux:
70
71```
72$ gox -osarch="linux/amd64"
73...
74```
75
76And more! Just run `gox -h` for help and additional information.
77
78## Versus Other Cross-Compile Tools
79
80A big thanks to these other options for existing. They each paved the
81way in many aspects to make Go cross-compilation approachable.
82
83* [Dave Cheney's golang-crosscompile](https://github.com/davecheney/golang-crosscompile) -
84 Gox compiles for multiple platforms and can therefore easily run on
85 any platform Go supports, whereas Dave's scripts require a shell. Gox
86 will also parallelize builds. Dave's scripts build sequentially. Gox has
87 much easier to use OS/Arch filtering built in.
88
89* [goxc](https://github.com/laher/goxc) -
90 A very richly featured tool that can even do things such as build system
91 packages, upload binaries, generate download webpages, etc. Gox is a
92 super slim alternative that only cross-compiles binaries. Gox builds packages in parallel, whereas
93 goxc doesn't. Gox doesn't enforce a specific output structure for built
94 binaries.
95
96