Created
August 29, 2018 06:10
-
-
Save haccer/c74e7d0ec4642848a12f3fb167071a73 to your computer and use it in GitHub Desktop.
Bash script to install the latest version of Go (For 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 | |
# 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