Skip to content

Instantly share code, notes, and snippets.

@csokun
Created September 18, 2020 12:14
Show Gist options
  • Save csokun/a1ddd2337bba9d39460ec62e7e1f423d to your computer and use it in GitHub Desktop.
Save csokun/a1ddd2337bba9d39460ec62e7e1f423d to your computer and use it in GitHub Desktop.
Download & Install Golang (Linux)
#!/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