Gocc
Go Cross-Compilation made easy.
Install / Use
/learn @skifli/GoccREADME
gocc
gocc (pronounced as /ɡɒtʃ/) makes cross-compilation for Go easy, by automating the process on all OSes. It allows for easy cofiguration of build architectures, and has pre-built binaries for all releases.
Installation
Using pre-built binaries
Pre-built binaries are made available for every x.x release. If you want more frequent updates, then run from source. Download the binary for your OS from the latest release. There are quick links at the top of every release for popular OSes.
[!IMPORTANT]
If you are on Linux or macOS, you may have to executechmod +x path_to_binaryin a shell to be able to run the binary.
Running from source
Use this method if none of the pre-built binaries work on your system, or if you want more frequent updates. It is possible that your system's architecture is different to the one that the binaries were compiled for (AMD).
[!NOTE]
You can check your system's architecture by viewing the value of theGOHOSTARCHenvironment variable.
- Make sure you have Go installed and is in your system environment variables as
go. If you do not have go installed, you can install it from here. - Download and extract the repository from here. Alternatively, you can clone the repository with Git by running
git clone https://github.com/skifli/goccin a terminal. - Navigate into the
/srcdirectory of your clone of this repository. - Run the command
go build main.go. - The compiled binary is in the same folder, named
main.exeif you are on Windows, elsemain.
Usage
usage: gocc [-h|--help] [_positionalArg_gocc_1 "<value>"] [-d|--dump "<value>"]
[-c|--config "<value>"]
Go Cross-Compiling made easy (v1.2.0). Get more information at
https://github.com/skifli/gocc
Arguments:
-h --help Print help information
--_positionalArg_gocc_1 The path to the file to cross-compile.
-d --dump The path to the folder to dump the
cross-compiled binaries in. Defaults to `build`
in the cwd. The specified folder will be created
if it does not exist.
-c --config The path to the config file.
Configuration
Example configuration files can be found in /config_examples.
How the configuration file works
Open /config_examples/allow.json. You will see two keys - mode, and targets. Mode can be a string of two values - allow, or disallow. The file you have just opened has the value of mode set to allow. This means that only the OS / Architecture combinitations in the list targets will be compiled for. targets is a list of strings containing the OS / Architecture combinations, in the form outputted from the command go tool dist list. This means windows/amd64 is valid, but not windows\amd64. If you ran the program with the configuration file you have open, it would only compile for all architectures under the OS Windows, and all OSes with the architecture 386 (32-Bit).
[!NOTE]
The*character can also be used to specify all targets. For example,windows/*applies to all architectures under the OS Windows, regardless of architecture;*/386applies to all OSes with the architecture386(32-Bit), regardless of OS.
Now open /config_examples/disallow.json. You will see the file is the exact same as the previously opened file, except for the fact that mode is set to disallow. This means that all OS / Architecture combinations in the list targets will not be compiled for, and all combinations not in the list will be compiled for. If you ran the program with the configuration file you have open, it would compile for all OSes except for Windows, and for architectures except for 386 (32-Bit).
[!NOTE]
If you provide a combination that does not exist, the program will ignore it, and no error will be raised. If the program encounters an error when parsing the config file, the script will output the culprit line / combination, and exit.
Known issues
#1 - loadinternal: cannot find runtime/cgo
This issue is caused by the runtime/cgo module being disabled. gocc will automatically enable runtime/cgo, but only if gcc is installed. This is because runtime/cgo requires gcc to be installed in PATH, so it can be used to compile C code. Instructions for installing gcc can be found below:
[!NOTE]
On macOS,clangandgccare the same, which is why the installation insutrctions for macOS say to installclang.
Related Skills
node-connect
347.2kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
xurl
347.2kA CLI tool for making authenticated requests to the X (Twitter) API. Use this skill when you need to post tweets, reply, quote, search, read posts, manage followers, send DMs, upload media, or interact with any X API v2 endpoint.
frontend-design
108.0kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
347.2kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
