First, go language installation
View Details: Go language Download, installation, configuration
Second, Golang plug-in introduction
for the Visual Studio Code development tool, there is an excellent Golang plugin whose homepage is: https://github.com/microsoft/vscode-go
Features of this plugin include:
- Code with color
- Code autocomplete (using Gocode)
- Code Snippets
- Quick Tip information (using GODEF)
- Jump to Definition (using GODEF)
- Search references (using go-find-references)
- Document Outline (using Go-outline)
- Renaming (using Gorename)
- Save build (using Go build and go test)
- Code formatting (using Goreturns or Goimports or gofmt)
- Debug code (using delve)
Third, plug-in installation 3.1 Visual Studio Code
find Microsoft's official website, download Visual Studio Code, website address https://code.visualstudio.com/
Click on the Red box, you can download other platform editor, such as:
The download installation process is omitted and the current version is:
3.2 Installing plugins
Go to Visual Studio Code, use the shortcut key F1, open the command panel
At the cursor • Enter Exten, and then select "Extensions:install Extension", such as:
Query plugin:
Show Plugin list:
In the list of plugins, select Go, install, and after installation, the system will prompt you to restart visual Studio Code.
3.3 Setting the environment variable Gopath
Set the GOPATH environment variable in the Windows system, my value is D:\GoWorks
Missing Gopath environment variables are usually reported as "$GOPATH not set." Such a mistake.
3.4 Turn on the visual Studio Code Auto-Protect feature
Open Visual Studio Code and locate the menu File->preferences->user Settings, such as:
Add or change the Settings.json "Files.autosave" property to "Onfocuschange" and save it.
3.5 Installing Git
The process of installing Git in Windows is omitted; Git\bin is configured into the PATH environment variable after installation.
Iv. plug-in configuration 4.1 Visual Studio Code Go plugin configuration options
The configuration options for Visual Studio code support the Go plugin settings, which can be configured via user preferences or workspace settings. You can find it at the menu file->preferences.
Set the Go configuration environment in Settings.json, such as:
4.2 Execute command
For details, please see the official website: Https://marketplace.visualstudio.com/items?itemName=lukehoban.Go
1) Install Gocode
Open a command prompt and enter:
go get -u -v github.com/nsf/gocode
To start the download:
Download Complete:
Download complete, view D:\GoWorks directory, more than one src\github.com\nsf\gocode path, such as:
Similarly, install the following 8 tools from the command line.
2) Install Godef
Go get-u-v github.com/rogpeppe/godef
3) Install Golint
Go get-u-v github.com/golang/lint/golint
4) Install Go-find-references
Go get-u-v github.com/lukehoban/go-find-references
5) Install Go-outline
Go get-u-v github.com/lukehoban/go-outline
6) Install Goreturns
Go get-u-v sourcegraph.com/sqs/goreturns
7) Install Gorename
Go get-u-v golang.org/x/tools/cmd/gorename
8) Install gopkgs
Go get-u-v github.com/tpng/gopkgs
9) Install Go-symbols
Go get-u-v github.com/newhook/go-symbols
3. Use Hello Word
1) file-> Open Folder, now working directory:
2) New Go file
Look, the smart tips come out.
The go language is also detailed in visual Studio code debugging.
Windows configures the Go Development environment (GO) through visual Studio code