WIN10 Environment Vscode+go Language environment construction

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

Go Environment Building

    • Go to the official website, download the MSI file directly and click Install.
    • Environment configuration: Mainly including Goroot Gopath GoBin, these three are the Go installation directory, go working directory (custom), and storage of the generated executable directory, the following is my environment variable configuration, for reference only (GoBin directory is also placed in the installation directory bin file , all can, I prefer to put in the working directory inside, feel very convenient):

      Environment variables. png
    • Open cmd or PowerShell, enter go version and Go env, and see the relevant information is configured successfully. Here you can see the details of your configuration.

      View Go info. png

Vscode Environment Configuration

  • After configuring the environment already, install Vscode, then install the Go plugin, then restart Vscode.
  • The next thing you need is to set Gopath and Goroot in the file-preferences-settings, which is basically done.

    Settings. PNG set in JSON.
  • However, if you want to run go on Vscode, you will also need to install some framework plugins. Install the version controller git first before installing because these are all to be obtained from GitHub, how to install these plugins, I have a direct point of way, is to create a new Hello.go project on the Vscode, this is you will directly see Vscode will prompt you to install some plug-ins, this is you directly click Install all, it will automatically help you to install the completed. After the installation is complete, you will see your new GitHub folder in your Gopath src directory, which is what you just installed. (because I've already installed it before, so this can't be done)
  • Of course you can also enter the following manual installation directly in CMD or PowerShell, the effect is the same.
      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-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  go get -u -v golang.org/x/tools/cmd/guru
  • OK, so you can come to your first go program.
      package main  import "fmt"  func main() {      fmt.Println("Hello, 世界")  }
  • Here again, you can install a code runner plugin in Vscode, directly right-click to run, of course, you can also go to the terminal hello.go file directory, run go install or go build, Then locate the Hello.exe file in the bin directory to run. The result is the same.

Image.png
Image.png

by Gai Xiao Classmate

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.