Skip to content

Instantly share code, notes, and snippets.

@thehowl
Created December 19, 2018 10:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thehowl/a2b7497af1c96cbb2e19087f639365d9 to your computer and use it in GitHub Desktop.
Save thehowl/a2b7497af1c96cbb2e19087f639365d9 to your computer and use it in GitHub Desktop.
uncomplicated crosscompilation of the major 9 platforms in go
#!/usr/bin/bash
# Looking at the source, I see.
# Bear with me. I can barely understand bash, let alone writing it.
# See that something can be done in a much better way? Just Pull Request It (tm)
if [ -z ${1+x} ]; then nproj=${PWD##*/}; else nproj=$1; fi
echo project name $nproj
for GOOS in darwin linux windows; do
for GOARCH in 386 amd64; do
echo "Building $GOOS-$GOARCH"
if [ $GOOS == "windows" ]; then extension=".exe"; else extension=""; fi
export GOOS=$GOOS
export GOARCH=$GOARCH
go build -o bin/$nproj-$GOOS-$GOARCH$extension
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment