8f42dedef8
* Add GO111MODULE=off to build.sh * Use golang 1.16 * Update go version in README.md * Add missing GO111MODULE=off * Add missing GO111MODULE=off again * Use go1.16.3 explicitly * Use 1.16 for CI test * Update min go version * Use go 1.16.4
55 lines
1.6 KiB
Bash
Executable File
55 lines
1.6 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
PREFERRED_GO_VERSION=go1.16.4
|
|
SUPPORTED_GO_VERSIONS='go1.1[56]'
|
|
|
|
GO_PKG_DARWIN=${PREFERRED_GO_VERSION}.darwin-amd64.pkg
|
|
GO_PKG_DARWIN_SHA=0f215de06019a054a3da46a0722989986c956d719c7a0a8fc38a5f3c216d6f6b
|
|
|
|
GO_PKG_LINUX=${PREFERRED_GO_VERSION}.linux-amd64.tar.gz
|
|
GO_PKG_LINUX_SHA=4a7fa60f323ee1416a4b1425aefc37ea359e9d64df19c326a58953a97ad41ea5
|
|
|
|
export ROOTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd )"
|
|
cd $ROOTDIR
|
|
|
|
# If Go isn't installed globally, setup environment variables for local install.
|
|
if [ -z "$(which go)" ] || [ -z "$(go version | grep "$SUPPORTED_GO_VERSIONS")" ]; then
|
|
GODIR="$ROOTDIR/.vendor/golocal"
|
|
|
|
if [ $(uname -s) = "Darwin" ]; then
|
|
export GOROOT="$GODIR/usr/local/go"
|
|
else
|
|
export GOROOT="$GODIR/go"
|
|
fi
|
|
|
|
export PATH="$GOROOT/bin:$PATH"
|
|
fi
|
|
|
|
# Check if local install exists, and install otherwise.
|
|
if [ -z "$(which go)" ] || [ -z "$(go version | grep "$SUPPORTED_GO_VERSIONS")" ]; then
|
|
[ -d "$GODIR" ] && rm -rf $GODIR
|
|
mkdir -p "$GODIR"
|
|
cd "$GODIR";
|
|
|
|
if [ $(uname -s) = "Darwin" ]; then
|
|
curl -L -O https://dl.google.com/go/$GO_PKG_DARWIN
|
|
shasum -a256 $GO_PKG_DARWIN | grep $GO_PKG_DARWIN_SHA
|
|
xar -xf $GO_PKG_DARWIN
|
|
cpio -i < com.googlecode.go.pkg/Payload
|
|
else
|
|
curl -L -O https://dl.google.com/go/$GO_PKG_LINUX
|
|
shasum -a256 $GO_PKG_LINUX | grep $GO_PKG_LINUX_SHA
|
|
tar xf $GO_PKG_LINUX
|
|
fi
|
|
|
|
# Prove we did something right
|
|
echo "$(go version) installed in $GODIR: Go Binary: $(which go)"
|
|
else
|
|
echo "$(go version) found in $GODIR: Go Binary: $(which go)"
|
|
fi
|
|
|
|
cd $ROOTDIR
|
|
|
|
# Configure the new go to be the first go found
|
|
export GOPATH=$ROOTDIR/.vendor
|