当前位置:网站首页>Go language development environment setup +goland configuration under the latest Windows

Go language development environment setup +goland configuration under the latest Windows

2022-06-24 09:57:00 BigChen_ up

One 、 download Go Language development package

You can Go Language website (https://golang.google.cn/dl/) download Windows Under the system Go Language development package , As shown in the figure below .
 Insert picture description here
Here we download 64 Bit development package , If the computer is 32 Bit system , You need to download 32 Bit development package , Scroll down in the page shown above to find 32 Download address of bit development package , As shown in the figure below .
 Insert picture description here

Be careful : download Windows Version of Go When developing language packages, try to choose MSI Format , Because it can be installed directly into the system , No additional operations are required .

Two 、 install Go Language development package

Double click to download OK Go Language development kit can start the installer , As shown in the figure below , This is a Go User license agreement for language , Don't worry about it , Check... Directly “I accept …” And then click “Next” that will do .

 Insert picture description here
stay Windows Under the system Go The language development package will be installed to by default C Discoid Go Under the table of contents , It is recommended to install in this directory , It is convenient to use . Of course , You can also choose another installation directory , Click after confirmation “Next”, As shown in the figure below :
 Insert picture description here
Go There are no other options to be set for the installation of language development package , Click on “Install” You can start the installation , As shown in the figure below :
 Insert picture description here
Wait for the program to complete installation , And then click “Finish” Quit Setup .

 Insert picture description here
After installation , Some directories and files will be generated under the installation directory we set , As shown in the figure below :
 Insert picture description here

3、 ... and 、 Set the environment variable

After the development package is installed , We also need to configure GOPATH environment variable , Can be used later Go Language development .GOPATH It's a path , It is used to store the code package needed in development .

Right click on the desktop or explorer “ This computer ”( perhaps “ My computer ”)→“ attribute ”→“ Advanced system setup ”→“ environment variable ”, As shown in the figure below .
 Insert picture description here
Find... In the pop-up menu GOPATH The corresponding options can be modified by clicking Edit , If not, you can choose to create a new one , And fill in the variable name as GOPATH, The variable value can be set to any directory ( Try to choose an empty directory ), for example D:\Go.

 Insert picture description here

Four 、 Development tools set environment variables intelligently

This tutorial uses GoLand development tool ,Goland Download below :

Goland Download and install
You can go from Goland Download the corresponding version of Goland Installation package
Official website download address :https://www.jetbrains.com/go/download/other.html

  • To configure GOROOT open GoLand Development tools Click :File/Settings/GOROOT Pictured :
     Insert picture description here
  • To configure GOPATH. open GoLand Development tools Click :File/Settings/GOPATH Pictured :
     Insert picture description here
    After the configuration is completed, you can run the code , stay D:\goProject Create a new folder test.go The documents are as follows :
package main

import "fmt"

func main() {
    
	fmt.Println("hello world")
}

 Insert picture description here

原网站

版权声明
本文为[BigChen_ up]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/175/202206240807401094.html