Linux command
gox 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
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]
说明
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.
参数
- -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.
FAQ
What is the gox command used for?
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.
How do I run a basic gox example?
Run `gox` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -osarch _TARGETS_ do in gox?
OS/arch combinations.