gox

Go cross-compilation tool

TLDR

Build for all platforms
$ gox
Build for specific platforms
$ gox -osarch="linux/amd64 darwin/amd64"
Build specific package
$ gox [./cmd/app]
Set output path
$ gox -output="dist/{{.Dir}}_{{.OS}}_{{.Arch}}"
Parallel builds
$ gox -parallel=[4]

SYNOPSIS

gox [options] [packages]

DESCRIPTION

gox is a simple Go cross-compilation tool that builds Go binaries for multiple platforms in parallel. It wraps `go build` with convenient cross-compilation options and templated output paths using OS and architecture variables.The tool simplifies creating release builds for multiple target platforms from a single command.

PARAMETERS

PACKAGES

Packages to build.
-osarch TARGETS
OS/arch combinations.
-os OS
Target operating systems.
-arch ARCH
Target architectures.
-output PATTERN
Output path template — supports `{{.Dir}}`, `{{.OS}}`, `{{.Arch}}`.
-parallel N
Number of concurrent build workers (default: number of CPUs).
-osarch-list-json FILE
Override the list of supported OS/arch combinations.
-cgo
Enable cgo (most cross-builds require an appropriate cross-compiler installed).
-rebuild
Rebuild the standard library for each target.
-ldflags FLAGS
Linker flags passed through to `go build`.
-tags TAGS
Build tags passed through to `go build`.
-mod MODE
Module download mode passed to `go build`.
--help
Display help information.

INSTALL

sudo apt install gox
sudo pacman -S gox
nix profile install nixpkgs#gox

CAVEATS

CGO may complicate cross-compile. Large number of targets is slow. Consider goreleaser for releases.

HISTORY

gox was created by Mitchell Hashimoto (HashiCorp) to simplify building Go binaries for multiple platforms.

SEE ALSO

go-build(1), goreload(1)