How Do You Install Golang on to Any Type of Linux?

Updated on 10/18/19

Problem scenario
You want to do some coding in the Go programming language.  You want a script to install Golang on any distribution of Linux (e.g., CentOS/Red Hat Enterprise Linux/Fedora, Debian/Ubuntu, or SUSE).  What do you do?

1.  Create a file in /tmp/ called with the following content:

version=1.10.8  # Change this version as needed
curl$version.linux-amd64.tar.gz > /tmp/go$version.linux-amd64.tar.gz
cp /tmp/go$version.linux-amd64.tar.gz /usr/local/go$version.linux-amd64.tar.gz
cd /usr/local/
tar xzvf go$version.linux-amd64.tar.gz
#echo "export PATH=""$""PATH:/usr/local/go/bin" >> ~/.profile
echo "export PATH=""$""PATH:/usr/local/go/bin" > /etc/profile.d/
echo "You will have to log out and log back in for go to work."
echo "You can use the 'go version' command to determine what version was installed"

2.  Run it like this:  sudo bash /tmp/

Leave a comment

Your email address will not be published. Required fields are marked *