Home > Backend Development > Golang > golang installation tutorial

golang installation tutorial

王林
Release: 2023-05-27 15:01:08
Original
872 people have browsed it

Among modern programming languages, Golang is a highly respected programming language. It has many advantages such as high efficiency, portability and practicality, and is one of the preferred languages ​​used by more and more software engineers and developers. In this article, we will detail how to install Golang on Windows and Linux operating systems.

  1. Installation on Windows

1.1 Download the installation package

First, we need to download the Golang installation package. Open the browser, select the operating system version that suits you on the official website (https://golang.org/dl/), and then download the corresponding installation package.

1.2 Install Golang

After downloading, double-click the installer to start the installation. Follow the installation prompts according to your needs. Of course, for most users, the default settings should be used until the installation is complete.

1.3 Configure environment variables

After successful installation, we need to add the Golang installation directory to the PATH environment variable. Open "Computer" (or "This PC"), right-click "Properties", select the "Advanced System Settings" menu, select "Environment Variables", find the system PATH, click Edit, and add the Golang installation path to the variable value. For example C:Go in.

1.4 Tips

Finally, open the command line and enter the following command:

go version

If the version information of Golang is displayed, it means that Golang has been Installed successfully and ready to go.

  1. Installation on Linux

2.1 Download the installation package

Open the terminal and use the following command to download the Golang installation package:

$ wget https://storage.googleapis.com/golang/go1.14.1.linux-amd64.tar.gz

In the above command, the installation package of this version of Golang is downloaded. Here we just take the current version as an example. After the download is complete, decompress the file through the following command:

$ tar -C /usr/local -xzf go1.14.1.linux-amd64.tar.gz

The above command will download the installation package to /usr/local directory and decompress it. After decompression, Golang is installed in the /usr/local/go directory.

2.3 Configure path

Next, we need to configure the Golang path in the system path. Open the terminal and enter the following command:

$ export PATH=$PATH:/usr/local/go/bin

Add to your ~/.bashrc according to the following command In the file:

$ echo "export PATH=$PATH:/usr/local/go/bin" >> ~/.bashrc

2.4 Verify installation

Finally, open the terminal and enter the following command:

$ go version

If the version information of Golang is displayed, it means that Golang has been successfully installed and is ready.

Summary

Installing Golang is a necessary step. Only through correct installation and configuration can Golang be used with the development environment. This article details the simple and clear steps to install Golang on Windows and Linux operating systems. Once you complete these steps, you can enjoy the efficiency and reliability that Golang brings.

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