Configure GoLang development environment for Visual Studio Code under Windows

table of Contents

One, go environment installation and configuration

Two, Visual Studio Code installation

Three, configure the Go plugin

Fourth, install Go tools

、 、 Hello World


One, go environment installation and configuration

Download link: https://golang.org/dl/

The downloaded version is go1.15.5.windows-amd64.msi , double click to install

Configure Path in the environment variable to add the bin directory of the go installation path, here is D:\Go\bin

If you want to modify the default workspace, you can modify the GOPATH parameter in the environment variable, the default %USERPROFILE%\go

Two, Visual Studio Code installation

Download link: https://code.visualstudio.com/

The installation steps are omitted, the version downloaded this time is:

Version: 1.51.1 (user setup)
Commit: e5a624b788d92b8d34d1392e4c4d9789406efe8f
Date: 2020-11-10T23:34:32.027Z
Electron: 9.3.3
Chrome: 83.0.4103.122
Node.js: 12.14.1
V8: 8.3.110.13-electron.0
OS: Windows_NT x64 10.0.18363

Three, configure the Go plugin

View->Extensiodins or click on the Extensiodins panel on the left, enter go, and click install

It is recommended to turn on auto save, File->Auto Save

Fourth, install Go tools

Integrated installation command, copy to CMD to install, restart Visual Studio after installation

go get -u -v github.com/nsf/gocode
go get -u -v github.com/rogpeppe/godef
go get -u -v github.com/golang/lint/golint
go get -u -v github.com/lukehoban/go-find-references
go get -u -v github.com/lukehoban/go-outline
go get -u -v sourcegraph.com/sqs/goreturns
go get -u -v golang.org/x/tools/cmd/gorename
go get -u -v github.com/tpng/gopkgs
go get -u -v github.com/newhook/go-symbols

、 、 Hello World

Create a new go file, output Hello World, Run->Run without Debugging, select Go

package main

import "fmt"

func main() {

	fmt.Println("Hello, world")
}

You can see that there are smart tips

Results of the

 

Command line execution

Guess you like

Origin blog.csdn.net/xlyrh/article/details/109777748