This is a creation in Article, where the information may have evolved or changed.
Author: Chszs, not allowed to be reproduced without the permission of Bo master. Permission to reprint should be marked by the author and blog home: Http://blog.csdn.net/chszs
Visual Studio Code is a development tool that I like very much. It would be interesting, then, to develop the Golang program by configuring the Golang development environment on visual Studio code. This article mainly describes the process.
First, the installation of Golang
Golang installation in Windows is relatively simple and the process is omitted.
Verify that:
D:\>go versiongo version go1.5.1 windows/amd64
Note that the installation of Golang to ensure that two environment variables, one is the GOROOT environment variable, and the other is the PATH environment variable to contain the $goroot\bin value.
Second, Golang plug-in introduction
For the Visual Studio Code development tool, there is a good Golang plug-in, its 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
1. Install Visual Studio Code version 0.10.2
Go to official website: https://code.visualstudio.com/
Download Visual Studio Code version 0.10.2, the installation process is slightly.
2, install the plug-in
Go to the Visual Studio code interface, use the shortcut key ctrrl+shift+p, open the command panel, select "Extensions:install Extension" and wait for the plugin list to load (this step is slower in the country).
Then in the input box "ext Install" Enter go, select Go 0.6.15, click Install, after the installation is completed requires restart development environment, click the Restart button, automatically refresh the environment.
3. Set GOPATH environment variable
Set the GOPATH environment variable in the Windows system, my value is D:\tools\VSCode\works
Missing Gopath environment variables are usually reported as "$GOPATH not set." Such a mistake.
4. Turn on Auto Save
It is highly recommended that the auto-save function be turned on. To open the method: Select Menu file, click Auto Save.
5. Install git
The process of installing Git in Windows is omitted. Remember to configure the Git\bin in the PATH environment variable.
Iv. Configuring Plugins
The configuration options for Visual Studio code support the settings of the Golang plugin and can be configured through user preferences or workspace settings. You can find it at the menu file->preferences.
1. Click User Settings
Found it
// Specifies the GOPATH to use when no environment variable is set."go.gopath": null,
If the GOPATH environment variable is not set, then this is the setting.
2. Execution of Orders
1) Install Gocode
go get -u -v github.com/nsf/gocode
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
3. Use
After the completion of the above, began Golang development is very convenient. :