Last active
August 8, 2020 16:56
-
-
Save theGeekPirate/c73491634e4680d80c41 to your computer and use it in GitHub Desktop.
Builds a Go debug binary for all supported platforms (excluding mobile)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
#From https://golang.org/doc/install/source#environment | |
platforms=(aix android darwin dragonfly freebsd illumos js linux netbsd openbsd plan9 solaris windows) | |
arches=(386 amd64 arm arm64 mips mipsle mips64 mips64le ppc64 ppc64le s390x wasm) | |
#.go file to build | |
test "$1" && target="$1" | |
if ! test "$target"; then | |
target="main.go" | |
fi | |
binaryName="$2" | |
for platform in "${platforms[@]}"; do | |
for arch in "${arches[@]}"; do | |
goos=${platform} | |
goarch=${arch} | |
output="$binaryName" | |
output="$(basename $target | sed 's/\.go//')" | |
[[ "windows" == "$goos" ]] && output="$output.exe" | |
destination="$(dirname $target)/builds/debug/$goos/$goarch/$output" | |
echo -e "\e[00;33mGOOS=$goos GOARCH=$goarch go build -o $destination $target\e[00m" | |
GOOS=$goos GOARCH=$goarch go build -o "$destination" "$target" | |
done | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment