Home  >  Article  >  Backend Development  >  Detailed explanation of the installation tutorial of Golang 1.9 (under Windows system)

Detailed explanation of the installation tutorial of Golang 1.9 (under Windows system)

PHPz
PHPzOriginal
2023-03-30 13:34:46766browse

Golang is a new programming language that is fast, safe and simple. Because of these features, it is favored by many programmers. If you want to start Golang programming, you first need to install the Golang environment. This article will introduce you to the specific steps to install the Golang 1.9 environment under Windows systems.

  1. Download the installation package

First, we need to download the Golang installation file from the official website. Before downloading, we must first confirm the basic information and version of our computer system. At the same time, please download the installation package suitable for your operating system and CPU architecture. For example, in our Windows system:

  • For 64-bit architecture systems, choose to download "go1.9.windows-amd64.msi ”
  • For 32-bit architecture systems, choose to download “go1.9.windows-386.msi”
  1. Install Golang

After the download is complete, install it. Please open the download directory and double-click the "go1.9.windows-amd64.msi" or "go1.9.windows-386.msi" file to perform the installation operation. In the pop-up "Golang Installation Wizard", we can click "Next" all the way to complete the installation and wait for the installation program to be automatically executed.

  1. Configuring Golang

3.1 Configure running environment variables

After the installation is completed, we need to configure the environment variables, that is, add Golang to the system environment variables .

Method 1: Manually configure the system environment variables

We can manually configure the environment variables through the following steps:

  • Press the Win R key combination to enter the running interface .
  • Enter sysdm.cpl and click [Advanced] > [Environment Variables] in the window that opens.
  • In the pop-up environment variable editing box, select [Path] under the [System Variables] column, and then click [Edit] to enter the environment variable editing interface.
  • In the environment variable editing interface, click [New], and then add the Golang installation directory (such as C:\Go\bin) to the path.
  • After saving the above path, reopen the Windows command line tool and execute the command go version to verify whether the installation is successful.

Method 2: Use a script to automatically configure environment variables

In Windows systems, you can automatically configure environment variables through the following script. The following script is suitable for 64-bit systems. If you need to use 32-bit systems, bit system, please change the c:\Go path to the path you actually installed.

$old = (Get-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Session Manager\Environment\').Path
$new = "$old;c:\Go\bin"
Set-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Session Manager\Environment\' -Name Path -Value $new
$env:Path = $new

After the above script is executed, reopen the Windows command line tool and execute the command go version to verify whether the installation is successful.

  1. Verify whether the installation is successful

After the installation is completed, we can verify whether the Golang environment is ready through the following command:

go version

After successful execution , will return Golang version number information. If the go command is not found, check whether the running environment variables are configured correctly.

At this point, the installation process of Golang 1.9 has ended. I hope this tutorial can help you successfully install the Golang environment and start your Golang programming journey.

The above is the detailed content of Detailed explanation of the installation tutorial of Golang 1.9 (under Windows system). 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