Installing go Lang and Adding it to PATH in Linux
Step 1 : Download the executable
1. get the latest version or your preferred version from the website: https://go.dev/dl/
e.g https://go.dev/dl/go1.26.2.linux-amd64.tar.gz
2. use wget to download it on your server:
wget https://go.dev/dl/go1.26.2.linux-amd64.tar.gz
3. Upon download completion, extract the downloaded zip
sudo tar -zxvf go1.17.linux-amd64.tar.gz -C /usr/local/
Step 2 : Setup the Go
- in this step you will need to configure the ${GOPATH} environment variable for GO
echo "export PATH=/usr/local/go/bin:${PATH}" | sudo tee /etc/profile.d/go.sh
source /etc/profile.d/go.sh
echo "export PATH=/usr/local/go/bin:${PATH}" | sudo tee -a $HOME/.profile source
source $HOME/.profile
2. To verify the setting above have applied successfully, run below command in terminal:
echo $PATH