Configuring the Go Development environment in visual Studio code

Source: Internet
Author: User
This is a creation in Article, where the information may have evolved or changed.

First, go language installation

View more:http://blog.csdn.net/langzi7758521/article/details/51313392

Second, Golang plug-in introduction

for the Visual Studio Code development tool, there is an excellent Golang plugin whose homepage is: https://github.com/microsoft/vscode-go

Features of this plugin include:

  • Colorization Code with color
  • Completion Lists Code Auto-complete (using Gocode)
  • Snippets Code Snippets
  • Quick Info Prompt information (using GODEF)
  • Goto definition jumps to definitions (using Godef)
  • Find References Search reference (using go-find-references)
  • File Outline Document Outline (using Go-outline)
  • Workspace symbol Search Workspace sign searching (using go-symbols )
  • Rename renaming (using Gorename)
  • Build-on-save Save build (using Go build and go test)
  • Format code formatting (using Goreturns or Goimports or gofmt)
  • Add Imports Reference (using gopkgs)
  • Debugging debug code (using delve)

Installation method:

git clone https://github.com/Microsoft/vscode-gocd vscode-gonpm install

For more details, see http://www.cnblogs.com/zsy/p/5224524.html

Third, plug-in installation

3.1 Visual Studio Code

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

Click on the Red box, you can download other platform editor, such as:

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

3.2 Installing plugins

Go to Visual Studio Code, use the shortcut key F1, open the command panel

At the cursor • Enter Exten, and then select "Extensions:install Extension", such as:

Query plugin:

Show Plugin list:

In the list of plugins, select Go, install, and after installation, the system will prompt you to restart visual Studio Code.

3.3 Setting the environment variable Gopath

Set the GOPATH environment variable in the Windows system, my value is D:\GoWorks


Missing Gopath environment variables are usually reported as "$GOPATH not set." Such a mistake.

3.4 Turn on the visual Studio Code auto-Save feature

Open Visual Studio Code and locate the menu File->preferences->user Settings, such as:

Add or change the Settings.json "Files.autosave" property to "Onfocuschange" and save it.

3.5 Installing Git

The process of installing Git in Windows is omitted; Git\bin is configured into the PATH environment variable after installation.

Iv. Plug-in configuration

4.1 Visual Studio Code Go plugin configuration options

The configuration options for Visual Studio code support the Go plugin settings, which can be configured via user preferences or workspace settings. You can find it at the menu file->preferences.

Set the Go configuration environment in Settings.json, such as:

4.2 Execute command

View the official website: Https://marketplace.visualstudio.com/items?itemName=lukehoban.Go

Integrated installation command, copy to cmd window to complete installation:

Go get-u-v github.com/nsf/gocodego get-u-v github.com/rogpeppe/godefgo get-u-v Github.com/golang/lint/golintgo Get- U-v Github.com/lukehoban/go-find-referencesgo get-u-v github.com/lukehoban/go-outlinego get-u-v Sourcegraph.com/sqs /goreturnsgo Get-u-V golang.org/x/tools/cmd/gorenamego get-u-v github.com/tpng/gopkgsgo get-u-v github.com/newhook/g O-symbols
Go get-v-u github.com/peterh/liner github.com/derekparker/delve/cmd/dlv

Not installed successfully, directly to the website to download such as:

Github.com/nsf/gocode 's code is placed in the

D:\GoWorks\src\github.com\nsf\gocode

then go to this folder and run the instructions : Go install.

This provides a script that simplifies running and saves as a batch file.

CD "C:\go\src\github.com\nsf\gocode"

Go Install


Download https://godoc.org/golang.org/x/tools/ to d:/goworks/src/golang.org/x/tools/

Restart vs code, as indicated in the lower right corner with analysis tool missing

Go to the appropriate path below

3. Use Hello Word

1) file-> Open Folder, now working directory:

2) New Go file

Look, the smart tips come out.

Reference: Https://marketplace.visualstudio.com/items?itemName=lukehoban.Go

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.