Home > Article > Backend Development > ubuntu install golang csdn
ubuntu Install golang
Under the ubuntu operating system, installing golang only requires a few simple steps. The following are some steps and methods to install golang.
Step 1: Check the system version
Enter the following command in the terminal to check the Ubuntu version.
lsb_release -a
The result should appear similar to the following information:
No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 20.04 LTS Release: 20.04 Codename: focal
Step 2: Download the golang binary file
Open the golang official website https://golang.org/dl/ , find the latest version and download it locally.
Step 3: Decompress the golang binary file
Extract the downloaded golang binary file to the directory that needs to be installed, such as:
sudo tar -C /usr/local -xzf go1.16.4.linux-amd64.tar.gz
Among them, "go1.16.4.linux -amd64.tar.gz" is the name of the downloaded golang package. Through the decompression operation, golang will be decompressed into the /usr/local/go folder.
Step 4: Set golang environment variables
Enter the following command in the terminal to set golang environment variables:
export PATH=$PATH:/usr/local/go/bin
Also, you can also add the above command to .bashrc file to permanently set environment variables.
sudo nano ~/.bashrc export PATH=$PATH:/usr/local/go/bin source ~/.bashrc
Step 5: Verify installation
Enter the following command in the terminal to view the golang version information.
go version
If the following information is prompted, it means the installation has been successful.
go version go1.16.4 linux/amd64
Step 6: Install the golang package
Enter the following command in the terminal to install the golang package.
go get github.com/gin-gonic/gin
The above command will install the Gin Web framework. With this command, the command line tool will automatically download, compile and install the Gin framework from Github.
After the installation is complete, you can test the Gin Web framework from the command line.
Summary
This article introduces how to install golang under the Ubuntu operating system. It is very suitable for developing web applications. By following the above steps, you can easily install golang on your local machine and be ready to use various packages and frameworks.
The above is the detailed content of ubuntu install golang csdn. For more information, please follow other related articles on the PHP Chinese website!