How to install Golang on Linux
Golang is a programming language developed by Google, and it is favored by many developers. Compared to other programming languages, Golang has excellent concurrency and network programming capabilities. Its efficiency and stability also make it widely used in cloud computing, network programming, distributed systems and other fields. It is very easy to install Golang on Linux systems. This article will introduce how to install Golang on Ubuntu and CentOS.
1. Install Golang on Ubuntu
Ubuntu is a Debian-based Linux distribution, so installing Golang on Ubuntu can be done using the Debian-based package manager apt.
The shortcut key to open the terminal in Ubuntu is Ctrl Alt T.
Enter the following command in the terminal:
sudo apt update
This command will update the system's Apt repository.
In Ubuntu, you can use the following command to install Golang:
sudo apt install golang
Download and install the latest Golang from the Apt repository Version.
Enter the following command in the terminal:
go version
If Golang is installed correctly, the current Golang version number.
2. Install Golang on CentOS
CentOS is a Linux distribution based on the same kernel as RHEL (Red Hat Enterprise Linux), so you can also use RPM package management to install Golang on CentOS. device to operate.
The shortcut key to open the terminal in CentOS is Ctrl Alt T.
Enter the following command in the terminal:
sudo yum install epel-release
This command will install the epel-release extension library of CentOS.
Enter the following command in the terminal:
sudo yum install git
Git is a code version control system, and Golang needs to rely on Git.
Enter the following command in the terminal:
wget https://dl.google.com/go/go1.14.2.linux-amd64.tar.gz sudo tar -C /usr/local -xzf go1.14.2.linux-amd64.tar.gz
This command will download Golang’s tar.gz compression from the Golang official website package and extract it to the /usr/local directory.
To allow the system to find the installed Golang, you need to add /usr/local/go/bin to the system’s PATH environment variable middle. Enter the following command in the terminal:
echo 'export PATH=$PATH:/usr/local/go/bin' >> ~/.bashrc source ~/.bashrc
This command will add /usr/local/go/bin to the system’s PATH environment variable and load this new environment variable in the terminal.
Enter the following command in the terminal:
go version
If Golang is installed correctly, the current Golang version number.
Conclusion
Installing Golang on a Linux system is very simple, whether it is on Ubuntu or CentOS, it can be installed through the package manager. Ubuntu uses Apt, CentOS uses RPM, and the installation is very convenient. Once Golang is successfully installed, you can start writing efficient, concurrent, and stable Go programs.
The above is the detailed content of How to install golang on linux. For more information, please follow other related articles on the PHP Chinese website!