Go related environment variable PATH gopath goroot

Source: Internet
Author: User

Goroot

The path to the go language installation, such as/usr/local/go under Mac, is similar to Java_home in Java.

Gopath

Gopath represents the address where the code package resides, and can be set more than one.

Assume: Gopath=~/go1:~/go2,goroot=/usr/local/go, the package is referenced in the code: Github.com/bitly/nsq/util

Then: The go program will compile in order to the following directory to find the source code:

~/go1/github.com/bitly/nsq/util

~/go2/github.com/bitly/nsq/util

/usr/local/go/github.com/bitly/nsq/util

If the package is not found in three directories, it will be an error.

PATH

The path to the executable program, which, when executed at the command line, is searched by default in the path specified in paths. For example, under Linux we use the most common LS command, we do not specify the path of the LS command, or switch to the directory where LS is located to execute the command. This is because the executable file of the LS command is in the same directory as the path entry.

After go installs, in the Goroot/bin directory, such as the Mac/usr/local/go/bin directory will have go, Godoc, gofmt three executable commands. To make it easy to use the go build and go install commands when compiling the GO project, you need to add the Goroot/bin directory to the system's path path.

Go related environment variable PATH gopath goroot

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.