This is a creation in Article, where the information may have evolved or changed.
Visual Studio code Download address
Https://code.visualstudio.com/Download
Golang Download Address
Https://www.golangtc.com/download
Download the. msi program from this address and double-click to install.
MSI installation program
Install the Go plugin in Vscode
Only need to query go plugin, install, restart, can.
Go Plugin Installation
Related configuration
1. Goroot Configuration
The default path is under the C:\GO directory, or you can select a different directory. When installed, Goroot is added to the system environment variable by default and the%goroot%/bin directory is added to the path. In cmd, execute go to see such as:
Goroot environment variable Configuration complete
2. GIT environment variable configuration
Because the Go plugin is installed in Vscode, you need to install some plugins together, such as command prompt. All need to be installed via Git.
Installing Git is not cumbersome, just add the bin directory under the GIT installation directory to%path%. CMD to execute the git command such as:
GIT environment variable configuration complete
3. Gopath Configuration
Gopath is used to put his own go project. Typically there are three folders under this directory: src, bin, pkg. You can execute the following command, which seems to automatically create a go directory in the user directory, and so on, the following tools are installed, will generate three directories, SRC, bin, pkg. Of course, you can create a new workspace for your go project. environment variable, add%gopath%, point to Workspace.
//代码自动提示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
First GO Project
Open Vscode, open folder with file, open Gopath, and in the SRC directory, create a new hello.go and write your "Hello World".
Open Gopath in Vscode
Run Hello.go
You can run the go running hello.go by vscode your own terminal. Go project. It can also be run in CMD.
Through the "View" and "Integrated Terminal", open the terminal vscode, the command line into the SRC directory under Gopath, run go run hello.go .
Run