cat > /tmp/install-go.sh << 'EOF'
#!/usr/bin/env bash
set -o errexit
set -o pipefail
set -o nounset
if [ "${1:-}" = '-v' ]; then
echo 'INFO: Verbose debug output enabled' 1>&2
set -o xtrace
shift
fi
VERSION='1.14'
OLD="$(go version | awk '{ print $3 }' | sed 's/^go//')"
curl -sSLO "https://dl.google.com/go/go${VERSION}.linux-amd64.tar.gz"
if [ -e '/usr/local/go' ]; then
sudo rm -rf "/usr/local/go-${OLD}"
sudo mv '/usr/local/go' "/usr/local/go-${OLD}"
fi
sudo tar -C '/usr/local' -xzf "go${VERSION}.linux-amd64.tar.gz"
rm "go${VERSION}.linux-amd64.tar.gz"
rm -rf /home/*/go/pkg
EOF
chmod a+x /tmp/install-go.sh
/tmp/install-go.sh -v
Last active
March 8, 2020 19:27
-
-
Save jaytaylor/938f92deeba27cf29dc074946ac41bfb to your computer and use it in GitHub Desktop.
Golang Linux quick installer
This file contains 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
#!/usr/bin/env bash | |
set -o errexit | |
set -o pipefail | |
set -o nounset | |
if [ "${1:-}" = '-v' ]; then | |
echo 'INFO: Verbose debug output enabled' 1>&2 | |
set -o xtrace | |
shift | |
fi | |
VERSION='1.14' | |
OLD="$(go version | awk '{ print $3 }' | sed 's/^go//')" | |
curl -sSLO "https://dl.google.com/go/go${VERSION}.linux-amd64.tar.gz" | |
if [ -e '/usr/local/go' ]; then | |
sudo rm -rf "/usr/local/go-${OLD}" | |
sudo mv '/usr/local/go' "/usr/local/go-${OLD}" | |
fi | |
sudo tar -C '/usr/local' -xzf "go${VERSION}.linux-amd64.tar.gz" | |
rm "go${VERSION}.linux-amd64.tar.gz" | |
rm -rf /home/*/go/pkg |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment