Go linux environment setup

Step 1: Download and Unzip the Go Linux Installation Package

wget -c https://go.dev/dl/go1.20.7.linux-386.tar.gz

Step 2: Extract the Downloaded Go Installation Package to the Installation Directory

tar -C /usr/local -xzf go1.20.7.linux-386.tar.gz

After executing the above extraction command, we will see a directory named go under /usr/local. This directory is the Go installation directory and is also the installation directory recommended by Go’s official documentation. We can view the contents of this installation directory with the following command

ls -F /usr/local/go

However, in order to use the go command from any path, we need to add the path where Go binary files are located to the user’s environment variable PATH (assuming the user is using bash). Specifically, add the following environment variable setting statement to the end of the $HOME/.profile file

export PATH=$PATH:/usr/local/go/bin

Then, execute the following command to make the above environment variable setting take effect immediately

source ~/.profile

Finally, we can verify whether the installation was successful with the following command

go version

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.