Configure the GO development environment in Visual Studio Code, studiocode

Source: Internet
Author: User
Tags install go gocode

Configure the GO development environment in Visual Studio Code, studiocode
I. GO language Installation

For details, see download, install, and configure GO.

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:

 

  • Colorization code with color
  • Completion the Lists code is automatically completed (using gocode)
  • Snippets code snippet
  • Quick Info prompt (use godef)
  • Goto Definition jump to Definition (use godef)
  • Find References search reference (use go-find-references)
  • File outline (use go-outline)
  • Workspace symbol search (Usego-symbols)
  • Rename (using gorename)
  • Build-on-save build (use go Build and go test)
  • Format code Format (using goreturns, goimports, or gofmt)
  • Add Imports Add reference (use gopkgs)
  • Debugging code (using delve)

For the installation tutorial of this plug-in, see vscode-go installation diary in Windows.

Iii. Plug-in installation 3.1 Visual Studio Code

Find Microsoft's official website, download Visual Studio Code, official site address https://code.visualstudio.com/

Click the red box to download the editors of other platforms, such:

The download and installation process is omitted. The current version is:

Go to Visual Studio Code, and press the shortcut key F1 to open the Command Panel.

Enter exten at the cursor and select "Extensions: Install Extension", for example:

Query plug-in:

Display the plug-in list:

In the plug-in list, select Go for installation. After installation, the system prompts you to restart Visual Studio Code.

3.3 set the environment variable GOPATH

Set the GOPATH environment variable in Windows. My value is D: \ GoWorks.


If the GOPATH environment variable is missing, an error such as "$ GOPATH not set." is usually reported.

3.4 enable Visual Studio Code automatic protection

Open Visual Studio Code and find File> Preferences> User Settings, as shown in the following figure:

Add or change the "files. autoSave" attribute of settings. json to "onFocusChange" and save the settings.

The installation of Git in Windows is omitted; after installation, git \ bin is configured to the PATH environment variable.

Set the go configuration environment in settings. json, for example:

For more information, 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

Start download:

Download completed:

Similarly, install the following eight tools through 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/#/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

2) create a go file

Look, the smart prompts are coming out.

The debug of the Go language in Visual Studio Code will be further detailed.

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.