Configuring the Go Development environment in Visual Studio code

Source: Internet
Author: User
Tags install go gocode sourcegraph


Configuring the Go Development environment in visual Studio code one, go language installation


View more: Go language download, installation, configuration


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:


    • 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 (usinggo-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)


For the installation tutorial of this plugin, please see the vscode-go installation Diary under Windows environment


Third, plug-in installation 3.1 Visual Studio Code


Find Microsoft's official website, download Visual Studio Code, official 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


For details, please see the official website: https://marketplace.visualstudio.com/items?itemName=lukehoban.Go



1) Install Gocode



Open a command prompt (open as Administrator) and enter:


go get -u -v github.com/nsf/gocode


To start the download:






Download Complete:





Download complete, view D:\GoWorks directory, more than one src\github.com\nsf\gocode path, such as:





Similarly, install the following 8 tools from 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/cmd/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








Integrated installation command, copy to cmd window to complete installation:
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
go get -u -v github.com/tpng/gopkgs
go get -u -v github.com/newhook/go-symbols
3. Use Hello Word


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









2) New Go file






Look, the smart tips come out.








Essay classification-The directory structure of the Go Language Go project summary: How the project directory structure is organized, the general language is not specified. But go language this aspect has made the stipulation, this can maintain the consistency, achieves unifies, the rule is more clear. 1, general, a go project under the Gopath, there will be the following three directories: |--bin |--pkg |--src where the bin holds the compiled executable file; pkg stores the compiled package file; src Store project source read the full text


Posted @ 2016-03-10 17:06 Dick Pig Read (10) | Comments (0) Edit


Go Language Exception Handling Defer\panic\recover summary: The go language pursues simplicity and elegance, so the go language does not support the traditional try...catch...finally, because the designers of the go language think that Mixing exceptions with control structures makes it easy to confuse your code. Because developers are prone to abuse exceptions, even a small error throws an exception. In the Go language, return errors using multivalued returns. Do not use exceptions instead of errors, not to read the full text


Posted @ 2016-03-01 08:44 Dick Pig read (6) | Comments (0) Edit


ODBC database driver for GO:GO Access SQL Server Summary via ODBC: The Go language accesses SQL Server through ODBC, which requires the GO-ODBC library, open Source address:: https://github.com/ WEIGJ/GO-ODBC driver installation in cmd Open gopath: Go to src directory in src directory via git get ODBC driver: Git clone Git://githu read the full text


Posted @ 2016-02-29 10:53 Dick Pig Read (12) | Comments (0) Edit


Vscode-go installation notes in the Windows environment Summary: First, Introduction for the Visual Studio Code development tool, there is a good Golang plug-in, its home page is: https://github.com/microsoft/ Vscode-go features of this plugin include: colorization code with color completion Lists Code autocomplete (use GoCo to read the full text


Posted @ 2016-02-28 12:42 Dick Pig read (175) | Comments (1) Edit


Configure the Go Development environment summary in Visual Studio code: First, Go language installation Details view: Go language Download, installation, configuration II, 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 The features of this plugin include: colorization read the full text


Posted @ 2016-02-28 01:08 Dick Pig read (410) | Comments (0) Edit


Go language Download, installation, configuration summary: First, go language download Go language official: https://golang.org/dl/find the right version for your system download, I downloaded the version of Windows. You can also download the source yourself for a deeper study of the go language. Second, go language installation after the download is complete, double-click Go1.6.windows-amd64.msi to install. If the installation process reads the full text


Posted @ 2016-02-24 22:08 Dick Pig Read (161) | Comments (0) Edit



About the Debug feature configuration for Visual Studio code, view: Vscode-go installation Diary under Windows environment



Configuring the Go Development environment in Visual Studio code


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.