Installation and environment variable settings for Go language under Windows platform

Source: Internet
Author: User
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
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.