Windows Visual Studio Code builds the Golang development environment

Source: Internet
Author: User
Tags windows visual

Objective

In fact, the environment is not difficult to build, but encountered some problems, mainly some site resources can not access (such as: golang.org),
Cause some packages can not be installed, will eventually lead to environmental failure, with this tutorial a few steps, we will be able to quickly build the Golang development environment.

Development environment:

First, installation

Here I need to install some tools:

1.Visual Studio Code 1.0.0

2.Golang Downloads

这里我使用的是Go1.6.

3.git Downloads

这一步跟建环境没什么关系,但是之后要引用一些包需要它.

4. Installing the Vscode-go Plugin

安装方法:打开vscode 按F1 然后选择安装扩展 选择go 下载后 重启

5. Download Vscode Extension Dependency tool

 vscode-go plug-ins require tools that are installed by default: 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-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/go-symbolsgo get-u-v Golang.org/x/tools/cmd/guru (and DLV Debug Run tool) The ultimate purpose of these content is to generate some EXE files in the Bin folder in Gopath. However, the installation here encountered some problems, some will install failure, error message The main meaning is that can not link ah, can not find AH and so on. Here I omit these steps. Download the EXE package I have generated directly, and put it in the Bin folder of Gopath. such as:              

Second, the configuration

1.GOPATH: This is your working directory, please specify your working directory in the system with a new gopath, and create a new one in the working directory
BIN,PKG,SRC of three folders.

2.Git: Add the Bin directory under the Git installation directory to the PATH environment variable.

3. Open the SRC folder with Vscode to add two files as follows:

{    "Files.autosave ":"Onfocuschange", "Go.buildonsave ":True, "Go.lintonsave ":True, "go.vetonsave ": true," go.buildTags ": Span class= "hljs-string" "" "," go.buildflags ": []," go.lintflags ": [] , "go.vetflags": [], "go.coveronsave":  False, "go.usecodesnippetsonfunctionsuggest": false, "go.formatonsave ": true," go.formatTool ": Span class= "hljs-string" > "Goreturns", "go.goroot":  "C:\\Go", " Span class= "hljs-attr" >go.gopath ": " H:\\projects\\github\\go ","  Go.gocodeautobuild ": true}         

{    "version": "0.2.0",    "configurations": [        {            "name": "Launch", "type": "go", "request": "launch", "mode": "debug", "remotePath": "", "port": 2345, "host": "127.0.0.1", "program": "${workspaceRoot}\\helloworld", "env": {}, "args": [] } ]}

Third, the demonstration

Run

Debugging

Iv. Summary

These libraries because can not get, I found on GitHub for a long time, finally compiled into EXE, the domestic find a few articles mentioned this problem,
So write a blog, let everyone convenient development. I hope you will enjoy learning the go language.

Turn:

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.