This is a creation in Article, where the information may have evolved or changed.
1. Go Language SDK installation package download and install
The latest stable version of the 1.5.3 installation package Go1.5.3.windows-amd64.msi download Address https://golang.org/dl/, about the size of the MB (the author uploaded a copy of the version of the installation package to CSDN resources, too slow to download foreign network: http ://download.csdn.net/detail/defonds/9408855), run the installation directly after download, the installation path uses its default C:\Go\Next and complete the installation.
2. Go Language environment variable setting
The Go language needs to configure both the Goroot and Path environment variables: goroot and Gopath.
2.1 root directory Goroot and Path
If the first step installation uses the default installation directory C:\Go\, the installer has set the Goroot and Path environment variables so that they do not need to be manually set.
If you do not use the default installation directory for the first step, you need to manually configure the above two variables, noting that the Path configuration does not affect other installers (such as Java,oracle,maven, etc.).
2.2 Go working directory Gopath
This is a follow-up code directory, create a new system variable Gopath, point it to your code directory:
2.3 Command line validation of environment variables
Open the CMD terminal and enter the go env to see if the variable is set successfully:
Note that the red box mark part is correct.
3. Writing the first Go program
Create a Hello.go file and edit its contents as follows:
Package Mainimport "FMT" Func Main () { fmt. Printf ("Hello, world\n")}
After saving, go to the directory and execute go run Hello.go:
See "Hello, World" to prove that our go installation was successful.
Resources
- The Go programming language-getting Started