Last active
May 16, 2021 20:34
-
-
Save renatoassis01/c4d80d78435441b289e8798c2b1a288b to your computer and use it in GitHub Desktop.
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
#! /bin/bash | |
set -euo pipefail | |
VERSION="1.16" | |
export GOROOT="$HOME/.go" | |
export GOPATH="$HOME/workspace/go" | |
ARCH="$(uname -m)" | |
PLATFORM="linux-$ARCH" | |
if [ -d "$GOROOT" ]; then | |
echo "The Go install directory ($GOROOT) already exists. Exiting." | |
exit 1 | |
fi | |
PACKAGE_NAME="go$VERSION.$PLATFORM.tar.gz" | |
TEMP_DIRECTORY=$(mktemp -d) | |
echo "Downloading $PACKAGE_NAME ..." | |
curl -s -o "$TEMP_DIRECTORY/go.tar.gz" https://storage.googleapis.com/golang/$PACKAGE_NAME | |
echo "Extracting File..." | |
mkdir -p "$GOROOT" | |
tar -C "$GOROOT" --strip-components=1 -xzf "$TEMP_DIRECTORY/go.tar.gz" | |
rm -f "$TEMP_DIRECTORY/go.tar.gz" | |
mkdir -p "${GOPATH}/"{src,pkg,bin} | |
echo -e "\nGo $VERSION was installed into $GOROOT.\nMake sure to relogin into your shell or run:" | |
echo -e "set export GOROOT="$HOME/.go in your shell config file" | |
echo -e "set export GOPATH="$HOME/workspace/go in your shell config file" | |
echo "Tip: Opening a new terminal window usually just works. :)" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment