Home  >  Article  >  Backend Development  >  How to build a go language development environment under windows

How to build a go language development environment under windows

王林
王林Original
2021-01-07 14:45:345998browse

How to build a go language development environment under windows: 1. Download the go language development package from the official website; 2. Install the go language development package; 3. Set the GOPATH environment variable; 4. Test whether the go development package is successfully installed. .

How to build a go language development environment under windows

#The operating environment of this article: windows10 system, GO 1.11.2, thinkpad t480 computer.

(Learning video sharing: Programming video)

The specific steps are as follows:

1. Download the go language development package

Everyone You can download the Go language development package under Windows system from the Go language official website (https://golang.google.cn/dl/), as shown in the figure below.

How to build a go language development environment under windows

Here we download the 64-bit development package. If the reader’s computer is a 32-bit system, you need to download the 32-bit development package, as shown in the picture above Scroll down on the page to find the download address of the 32-bit development package, as shown in the figure below.

How to build a go language development environment under windows

Note: When downloading the Windows version of the Go language development package, try to choose the MSI format, because it can be installed directly into the system without additional operations.

3. Install the go language development package

Double-click the Go language development package we downloaded to start the installation program, as shown in the figure below. This is the user license agreement for the Go language. No need to worry about it. Just check "I accept..." and click "Next".

How to build a go language development environment under windows

Under Windows systems, the Go language development package will be installed in the Go directory of the C drive by default. It is recommended to install it in this directory, which is more convenient to use. Of course, you can also choose other installation directories, and click "Next" after confirming that it is correct, as shown in the figure below:

How to build a go language development environment under windows

There is no other installation method for the Go language development package. For the options that need to be set, click "Install" to start the installation, as shown in the following figure:

How to build a go language development environment under windows

Wait for the program to complete the installation, and then click "Finish" to exit the installation program .

How to build a go language development environment under windows

#After the installation is completed, some directories and files will be generated in the installation directory we set, as shown in the figure below:

How to build a go language development environment under windows

The structure of this directory follows the GOPATH rules. This concept will be mentioned in the following chapters. The meaning of each folder in the directory is as shown in the following table.

How to build a go language development environment under windows

#When developing, there is no need to pay attention to these directories. If readers want to understand the underlying principles in depth, they can continue to explore through the above introduction.

4. Set environment variables

After the development package is installed, we also need to configure the GOPATH environment variable before we can use the Go language for development. GOPATH is a path used to store code packages needed for development.

Right-click "This Computer" (or "My Computer") on the desktop or explorer → "Properties" → "Advanced System Settings" → "Environment Variables", as shown in the figure below.

How to build a go language development environment under windows

Find the option corresponding to GOPATH in the pop-up menu and click Edit to modify it. If not, you can choose to create a new one and fill in the variable name as GOPATH and set the variable value. It can be any directory (try to choose an empty directory), such as D:\Go.

How to build a go language development environment under windows

Tip: After filling in, you need to click "OK" in each open window to save the settings.

Other environment variables in the installation package will be automatically set. By default, Go will be installed in the directory c:\go, but if you modify the installation directory during the installation process, you may need to manually modify the values ​​of all environment variables.

After the environment variables are set, open the cmd window and enter the go env command to test.

How to build a go language development environment under windows

Only part of the results are shown above. If results similar to the above appear after executing the go env command, it means that our Go development package has been installed successfully.

Related recommendations: golang tutorial

The above is the detailed content of How to build a go language development environment under windows. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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