# This is a generalized function to build a statically-linked release binary. # It specifies all the Go flags needed to make that happen depending on the platform. build(){ OS=$1 ARCH=$2 if [ -z $NAME ] then NAME=output fi if [ -z "${CC}" ] then export CC=gcc fi LDFLAGS_WIN="" EXE="" if [ "${OS}" == "windows" ] then LDFLAGS_WIN="-H windowsgui" EXE=".exe" fi OUTPUT="${NAME}-${OS}-${ARCH}${EXE}" export CGO_ENABLED=1 export CC="${CC}" export GOOS=$OS export GOARCH=$ARCH go build -x -v \ -trimpath \ -tags static \ -ldflags="-s -w ${LDFLAGS_WIN}" \ -o "${OUTPUT}" }