Default value for "Translate" Gopath

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

Starting with Go 1.8, if the GOPATH environment variable is empty, go will set a default Gopath environment variable.

When go beginners install go for the first time, they tend to get the error that you had to set a gopath because they forgot to set the GOPATH environment variable. The priority of this requirement is getting higher. For new users of Go, explaining the role of Gopath and directing them to set up Gopath will make it impossible for them to focus on go. Especially sometimes, these people are not going to use the go language to develop, but instead use go get to download some necessary commands.

Go 1.8 will set the default Gopath. If you do not set the Gopath,go yourself, the default value will be used. The default Gopath is:

    • It's in the directory on the Unix-like system. $HOME/go
    • Under Windows System is%USERPROFILE%\go

Although the default Gopath is already available, it does not solve all the problems:

    • We still have to add them $GOPATH/bin to the PATH inside so that they go get can be run directly through the binaries installed with go install. (The Translator notes: Of course, it is possible to run these programs through an absolute path, but it is more troublesome).
    • The Go language developer still needs to understand the role of Gopath and its directory structure.
    • If your GOROOT path (which is where you let go source) is the same as the default Gopath, and you do not set a default Gopath,go, it is not to set the default gopath for you, because it will confuse the contents of Goroot.

When you have questions, you can run the command go env GOPATH to check the path of the Gopath. If there is a problem, such as what is said above, go does not automatically generate Gopath, this command will print empty.

Read the original The default Gopath

The original link: "Translation" Gopath default value, reprint please indicate the source!

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.