Home  >  Article  >  Backend Development  >  Golang windows installation steps explained

Golang windows installation steps explained

PHPz
PHPzOriginal
2023-03-29 09:45:021724browse

Golang is a very popular programming language. It has efficient and flexible features, so it has attracted more and more developers to use it. For Windows systems, installing Golang is also very simple. The specific steps are described below.

  1. Download the installation file

Visit the Golang official website (https://golang.org/dl/) and choose the installation package suitable for your system , download the corresponding installation file.

  1. Installing Golang

After the download is complete, double-click to run the installation file and select a custom installation path.

Next, configure the environment variables:

Right-click "PC" -> Select "Properties" -> Click "Advanced System Settings" -> Click Environment Variables -> Click System "New" of the variable -> Fill in "GOROOT" for the variable name, and the variable value is the installation path of Golang.

Then you need to configure GOPATH. This path is usually placed in the user's workspace.

Right-click "PC" -> Select "Properties" -> Click "Advanced System Settings" -> Click Environment Variables -> Click "New" for system variables -> Fill in "GOPATH" for the variable name ”, the variable value is the customized workspace path.

  1. Test installation

After the installation is completed, open the command prompt tool and enter "go version". If the version number output appears, it means that Golang has been installed successfully. At the same time, you can also enter some sample code to verify.

  1. Configuration Editor

Golang supports multiple IDEs and editors, such as: VSCode, Atom, Goland, etc. Just choose any editor you like. After installation, you need to configure it.

Take VSCode as an example, use the shortcut key "Ctrl Shift X" to open the plug-in panel, search for "Golang", install the "Microsoft Go" plug-in, and then press the shortcut key "Ctrl," to open the settings file. Modify the following content:

{

"go.formatTool": "goimports",
"go.toolsEnvVars": {
    "GOPATH": "${env:GOPATH}"
},
"go.gopath": "${env:GOPATH}"

}

If you need to use the IntelliSense function of VSCode, you need to install the corresponding components: gocode, gopkgs, govendor, golint, gotests.

  1. Writing a Hello World program

After completing the above steps, you can use the editor to create the first Golang program - Hello World.

package main

import "fmt"

func main() {

fmt.Println("Hello Golang!")

}

Save the code in the editor, Right-click and select "Run in Terminal". If "Hello Golang!" is output, the program runs successfully.

Summary:

The above are the detailed steps for installing Golang on Windows systems. I believe that for developers who have just started using Golang, it can help them quickly complete the installation and configuration and start efficient Programming.

The above is the detailed content of Golang windows installation steps explained. 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