Home > Backend Development > Golang > ubuntu install golang csdn

ubuntu install golang csdn

WBOY
Release: 2023-05-15 11:53:37
Original
808 people have browsed it

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
Copy after login

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
Copy after login

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
Copy after login

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
Copy after login

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
Copy after login

Step 5: Verify installation

Enter the following command in the terminal to view the golang version information.

go version
Copy after login

If the following information is prompted, it means the installation has been successful.

go version go1.16.4 linux/amd64
Copy after login

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
Copy after login

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!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template