Install golang on Linux
1. Familiarize yourself with common commands#
# Uninstall software
apt-get autoremove package_name
# Update environment variables
source $HOME/.profile
# Modify environment variables
vim /etc/profile
2. Go installation.#
Select the tab for your computer's operating system below and follow its installation instructions.
Linux Mac Windows
-
Extract the downloaded archive to /usr/local, creating a Go tree in /usr/local/go.
Important: This step will remove any previous installation of Go in /usr/local/go before extraction (if any). Please backup all data before proceeding.
For example, run the following command as root or with
sudo
:rm -rf /usr/local/go && tar -C /usr/local -xzf go1.14.3.linux-amd64.tar.gz
-
Add /usr/local/go/bin to the PATH environment variable.
PATH
You can do this by adding the following line to your $HOME/.profile or /etc/profile (for system-wide installation):
export PATH=$PATH:/usr/local/go/bin
Note: Changes made to the configuration files may not take effect until you log in to your computer again. To apply the changes immediately, simply run the shell command directly or from a configuration file using a command such as .
Update environment variables
source $HOME/.profile source /etc/profile
-
Verify that Go is installed by opening a command prompt and typing the following command:
$ go version
-
Confirm that the command prints the installed Go version.