Skip to content

Instantly share code, notes, and snippets.

@vijay922
Forked from haccer/install_go.sh
Created May 6, 2019 12:40
Show Gist options
  • Save vijay922/ff35ad49608f6f6b159ee27a486f7f1b to your computer and use it in GitHub Desktop.
Save vijay922/ff35ad49608f6f6b159ee27a486f7f1b to your computer and use it in GitHub Desktop.
Bash script to install the latest version of Go (For linux)
#!/bin/bash
# Bash script to install the latest version of Go (For linux)
# Get current version of Go for 64-bit Linux
CUR=$(curl -s https://golang.org/dl/ | grep linux-amd64 | grep 'download downloadBox' | cut -d'"' -f4)
# Download Go
wget $CUR
# Get filename
FILE=$(echo $CUR | cut -d'/' -f5)
# Unpack file to /usr/local
sudo tar -C /usr/local -xzf $FILE
# Remove Go .tar.gz
rm $FILE
# Make GOPATH
mkdir ~/.golang
# Set env
echo '' >> ~/.bashrc
echo '# Golang' >> ~/.bashrc
echo 'export PATH=$PATH:/usr/local/go/bin' >> ~/.bashrc
echo 'export GOPATH=$HOME/.golang' >> ~/.bashrc
echo 'export PATH=$PATH:$GOPATH/bin' >> ~/.bashrc
source ~/.bashrc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment