#!/usr/bin/env bash# based on https://www.digitalocean.com/community/tutorials/how-to-build-go-executables-for-multiple-platforms-on-ubuntu-16-04package=$1if [[ -z "$package" ]]; then echo "usage: $0 <package-name>" exit 1fipackage_name=$(basename $package .go)# see here for list of os's and architectures: https://golang.org/doc/install/source#environmentplatforms=("windows/amd64" "windows/386" "darwin/amd64" "linux/amd64")for platform in "${platforms[@]}"do platform_split=(${platform//\// }) GOOS=${platform_split[0]} GOARCH=${platform_split[1]} output_name=$package_name'-'$GOOS'-'$GOARCH if [ $GOOS = "windows" ]; then output_name+='.exe' fi env GOOS=$GOOS GOARCH=$GOARCH go build -o $output_name $package if [ $? -ne 0 ]; then echo 'An error has occurred! Aborting the script execution...' exit 1 fidone