Home > Backend Development > Golang > golang 2019 installation

golang 2019 installation

WBOY
Release: 2023-05-22 19:03:06
Original
592 people have browsed it

Golang is an open source programming language launched by Google in 2007. Since its launch, it has been favored by programmers. Golang-based applications have the characteristics of high efficiency, high concurrency, and convenient development, and are suitable for network servers, distributed systems, cloud computing and other fields.

So, how to install Golang in 2019? This article will introduce you to the Golang installation process in detail and help you easily get started writing Golang programs.

Preparation before Golang installation

Before installing Golang, you need to ensure that the operating system is a 64-bit version and that GCC and Glibc are installed. GCC is a compiler used to compile source code into executable files. Glibc is an important GNU library that contains many C language function libraries. For writing portable Linux applications.

Installing Golang

1: Download Golang

Before installing Golang, you need to download the Golang binary package from the official website. The official website address is https://golang.org/dl/. Among them, according to your needs, select the binary package suitable for your operating system to download. In this article, we choose the binary package on the Linux platform. Save the downloaded binary package locally, for example, in /home/work/go1.12.1.linux-amd64.tar.gz.

2: Decompress the Golang installation package

After downloading and saving the Golang binary package, you can use the command line tool in Linux to decompress it. Open the terminal command line tool, go to the directory where the Golang binary package is saved, and use the following command to decompress it.

$ tar zxvf go1.12.1.linux-amd64.tar.gz
Copy after login

After decompression, a folder named go will be generated in the current directory.

3: Set environment variables

In order for Golang to run normally in the system, it needs to be added to the environment variables. Open the terminal command line tool and edit the system environment variable configuration file. In this article, we are using the vi editor. Enter the following command in the terminal command line to open the system environment variable configuration file:

$ sudo vi /etc/profile
Copy after login

Add the following content at the end of the file:

export GOROOT=/home/work/go
export GOPATH=/home/work/gopath
export GOBIN=$GOPATH/bin
export PATH=$PATH:$GOROOT/bin:$GOBIN
Copy after login

Among them, GOROOT represents the installation path of Golang, and GOPATH represents your The working directory, GOBIN represents the storage path of the executable file, and PATH represents the execution path in the system environment variable.

After the editing is completed, use the following command to make the environment variable configuration file take effect:

$ source /etc/profile
Copy after login

Four: Test whether the installation is successful

After completing the above steps, you need to test whether Golang is installed successfully. . Open the terminal command line tool and enter the following command:

$ go version
Copy after login

If the terminal outputs Golang version information, the installation is successful.

Summary

The above are the detailed steps for installing Golang on the Linux platform. Golang has the advantages of high efficiency, high concurrency, and ease of development, and is suitable for network servers, distributed systems, cloud computing and other fields. I hope this article can provide some help to programmers and make it easier for everyone to play with Golang.

The above is the detailed content of golang 2019 installation. 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