VSCode Go build environment (Windows version)

  1. The first step, install Go in VSCode the extension, search Go

  1. Landing https://studygolang.com/dl, go download the corresponding version of the installation package, here is the windows version

  1. Installation step by step by step installation go language, recommended to choose the default installation path, the default installation path is automatically generated in the environment variable GOROOT

  1. Select a location, establish github folder, create a folder under golang github, this path is GOPATH as our path, and then create three folders, respectively pkg, bin and src at golang folder where to store our own pkg the project package, bin store our own good project compiled executable file, src store source code for our own projects, as follows

  1. Set system environment variables, adding GOROOT as C: \ go (go here is your installation directory); catalog add user environment variables GOPATH build your own golang folder, here is ... / github / golang, win + R open command-line tool, input cmd, enter, input Version go, as if the display is disposed in a windows environment go complete language

  1. Establish himself at github / golang / src folder hello.go for a test, as follows
package main
import "fmt"
func main(){
  fmt.Println("Hello World!")
}

Open a command line, cd to the next github / golang / src folder, run go run hello.go, if the show follows the successful run

  1. Then go to build VSCode the environment, where it is recommended VSCode need to restart, open the src folder after the restart, then VSCode will be prompted to install the necessary packages, click on the install, run the code

  1. I can see hello.go successfully compile and run!

Guess you like

Origin www.cnblogs.com/htc524/p/12616839.html