Skip to content

Instantly share code, notes, and snippets.

@Lajule
Last active July 22, 2021 09:19
Show Gist options
  • Save Lajule/0d4a04a05065647786ee64a1ee76fbe0 to your computer and use it in GitHub Desktop.
Save Lajule/0d4a04a05065647786ee64a1ee76fbe0 to your computer and use it in GitHub Desktop.
Golang cross compiling
#!/bin/bash
set -ex
cwd="${PWD}"
for goos in darwin linux windows; do
for goarch in 386 amd64; do
(cd "${0%/*}" \
&& GOOS="${goos}" GOARCH="${goarch} go build -o "${cwd}/${1}_${goos}_${goarch}") || exit $?
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment