A simple command-line tool to cross-compile Go applications based on a YAML configuration file.
-
Download: Go to the releases page and download the correct binary for your system.
-
Prepare the Executable:
For Windows:
- Rename the downloaded file (e.g.,
gobuild-windows-amd64.exe) togobuild.exe.
For macOS & Linux:
-
Rename the downloaded file (e.g.,
gobuild-linux-amd64) togobuild. -
Make it executable:
chmod +x gobuild
- Rename the downloaded file (e.g.,
-
Add to PATH (Recommended): To use
gobuildfrom any terminal, move it to a directory in your system's PATH.For Windows:
- Move
gobuild.exeto a folder that is in your PATH (e.g.,C:\Windows\System32), or add a new folder (e.g.,C:\Tools) to your PATH.
For macOS & Linux:
-
Move the
gobuildfile to/usr/local/bin:sudo mv gobuild /usr/local/bin/
- Move
Once installed, run the tool from your project directory:
gobuild config.yamlThis will compile your project based on the settings in config.yaml and place the binaries in a builds directory.
Create a config.yaml file to define your build targets.
source_dir: The directory of your Go application's main package. Defaults to.if not specified.build_name: The base name for the compiled binaries.builds: A list of target platforms, each with agoos(OS) andgoarch(architecture).
# The directory of your Go application's main package.
# Defaults to the current directory (".") if not specified.
source_dir: .
# The base name for the output binaries.
build_name: my-app
# A list of target platforms to build for.
builds:
- goos: windows # Target operating system (e.g., windows, linux, darwin).
goarch: amd64 # Target architecture (e.g., amd64, arm64).
- goos: linux
goarch: amd64
- goos: darwin
goarch: amd64