Configure GoLang development environment in Visual Studio Code

Source: Internet
Author: User
Tags install go gocode

Configure GoLang development environment in Visual Studio Code

Visual Studio Code is a development tool that I like very much. Therefore, if you can configure the GoLang Development Environment on Visual Studio Code to develop the GoLang program, it is undoubtedly interesting. This article describes this process.

1. Installation of GoLang
GoLang installation in Windows is relatively simple and the process is omitted.

Verify:

D: \> go version
Go version go1.5.1 windows/amd64
Note that the installation of GoLang requires two environment variables, one being the GOROOT environment variable, and the other being the PATH environment variable containing the $ GOROOT \ bin value.

2. Introduction to GoLang plug-ins
For Visual Studio Code development tools, there is a good GoLang plug-in, its home page: https://github.com/microsoft/vscode-go

Features of this plug-in include:

Code-colored
Automatic Code Completion (using gocode)
Code snippet
Quick message (using godef)
Jump to definition (use godef)
Search reference (use go-find-references)
File outline (use go-outline)
Rename (using gorename)
Save build (use go build and go test)
Code formatting (using goreturns, goimports, or gofmt)
Debug code (using delve)
Iii. Plug-in Installation
1. Install Visual Studio Code 0.10.2
Go to the official website: https://code.visualstudio.com/
Download Visual Studio Code 0.10.2. The installation process is omitted.

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 plug-in name list to load (this step is slow in China ).
In the "ext install" text box, enter go, select go 0.6.15, and click install. After installation, restart the development environment and click restart to automatically refresh the environment.

3. Set GOPATH Environment Variables
Set the GOPATH environment variable in Windows. My value is D: \ tools \ VSCode \ works.
If the GOPATH environment variable is missing, an error such as "$ GOPATH not set." is usually reported.

4. Enable auto save
We strongly recommend that you enable the auto save function. To enable this function, select File and click Auto save.

5. Install Git
The installation of Git in Windows is omitted. Remember to configure git \ bin to the path environment variable.

Iv. Configure plug-ins
The configuration options of Visual Studio Code support GoLang plug-in settings, which can be configured through user preference settings or workspace settings. Choose File> Preferences from the menu.

1. Click User Settings
Find

// Specifies the GOPATH to use when no environment variable is set.
"Go. gopath": null,
If the GOPATH environment variable is not set, set it here.

2. execute commands
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/#/gorename

3. Use
After the preceding steps are completed, it is very convenient to start GoLang development. :

Use Visual Studio Code to develop TypeScript

Visual Studio Code simple trial

Visual Studio Code trial

Visual Studio 2010 & Help Library Manager installation instructions

How to configure OpenCV 2.3.x/2.4.x in Visual Studio 2005/2008 and Visual Studio 2010

Use the opencv-2.4.0.exe file to compile the x86 or x64 platform Visual Studio 2005/2008/2010 target file

Visual Studio LightSwitch supports HTML5 and JavaScript

Visual Studio 11: use C ++ to develop a simplest Metro application

Visual Studio details: click here
Visual Studio: click here

This article permanently updates the link address:

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.