Created
September 18, 2020 12:14
-
-
Save csokun/a1ddd2337bba9d39460ec62e7e1f423d to your computer and use it in GitHub Desktop.
Download & Install Golang (Linux)
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 | |
GOPATH=$(which go) | |
if [ -n "$GOPATH" ]; then | |
echo "Go installed: $GOPATH" | |
go version | |
exit 1 | |
fi | |
VERSION=1.15.2 | |
PKG_NAME="go${VERSION}.linux-amd64.tar.gz" | |
URL="https://golang.org/dl/${PKG_NAME}" | |
echo "Download golang $URL" | |
curl -L $URL -o /tmp/$PKG_NAME | |
echo "Install golang $VERSION" | |
cd /tmp | |
sudo tar -C /usr/local -xzf $PKG_NAME | |
rm /tmp/$PKG_NAME | |
if ! grep -q /usr/local/go/bin ~/.profile; then | |
echo "export PATH=$PATH:/usr/local/go/bin" >> ~/.profile | |
fi | |
go version |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment