Win+vscode+golang Configuration

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

Visual Studio code Download address

Https://code.visualstudio.com/Download

Golang Download Address

Https://www.golangtc.com/download
Download the. msi program from this address and double-click to install.


MSI installation program

Install the Go plugin in Vscode

Only need to query go plugin, install, restart, can.



Go Plugin Installation

Related configuration

1. Goroot Configuration
The default path is under the C:\GO directory, or you can select a different directory. When installed, Goroot is added to the system environment variable by default and the%goroot%/bin directory is added to the path. In cmd, execute go to see such as:


Goroot environment variable Configuration complete

2. GIT environment variable configuration
Because the Go plugin is installed in Vscode, you need to install some plugins together, such as command prompt. All need to be installed via Git.
Installing Git is not cumbersome, just add the bin directory under the GIT installation directory to%path%. CMD to execute the git command such as:


GIT environment variable configuration complete

3. Gopath Configuration
Gopath is used to put his own go project. Typically there are three folders under this directory: src, bin, pkg. You can execute the following command, which seems to automatically create a go directory in the user directory, and so on, the following tools are installed, will generate three directories, SRC, bin, pkg. Of course, you can create a new workspace for your go project. environment variable, add%gopath%, point to Workspace.

//代码自动提示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

First GO Project

Open Vscode, open folder with file, open Gopath, and in the SRC directory, create a new hello.go and write your "Hello World".


Open Gopath in Vscode

Run Hello.go

You can run the go running hello.go by vscode your own terminal. Go project. It can also be run in CMD.
Through the "View" and "Integrated Terminal", open the terminal vscode, the command line into the SRC directory under Gopath, run go run hello.go .


Run
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.