This is a creation in Article, where the information may have evolved or changed.
First, the installation of Golang
Golang Install and verify:
[cox@localhost ~]$ sudo pacman -S go[cox@localhost ~]$ go versiongo version go1.8.3 linux/amd64s
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
[cox@localhost ~]$ sudo pacman -S visual-studio-code
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.62, click Install, after the installation is completed requires restart development environment, click the Restart button, automatically refresh the environment.
3. Set GOPATH environment variable
See: Linux Configuration Gopath (Go language Development Code storage directory)
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
[cox@localhost ~]$ sudo pacman -S git
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