Gopath Settings under Windows

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

Download the Go Language installation package, then install it and set it to three places:

1. In the path variable of windows, add the directory where Go's executable file is located:

[JavaScript]View Plaincopy
    1. Path=c:\go\bin; other settings;

2. Set Goroot, this good understanding, directly set into C:\Go can

[JavaScript]View Plaincopy
    1. Goroot=c:\go

3. Set Gopath, this is hard to understand, I try:

[Python]View Plaincopy
    1. Gopath= #就是等于空, this can be set in the system environment variables, the results of the error go get packet when the error said $gopath not set
    2. gopath=; #就是等于一个分号 (;), go get package start can run, no error, and finally error, said $gopath not set
    3. Gopath=c:\go or Gopath=c:\go; #go Get packet error, said $gopath can not be set to the same as Goroot

The Final Solution is:

Create a directory in the C drive called Gopath, and then set up Gopath=c:\gopath,

[Python]View Plaincopy
    1. Gopath=c:\gopath


Go get package can be used, the final package will be installed into the C:\GOPATH\ directory of the PKG and src folder, pkg is *.a format, for the moment to understand the library bar, src directory is *.go format source code.

Summarize

In fact, Gopath can be a list of directories, when set in Windows environment variables, multiple directories using semicolons (;) separated, multiple directories in Linux using colons (:) separated by a string of combinations.

Gopath is a list of directories that are listed for go to find packages. When using the import "package name", if you can't find it in Goroot, you should turn to your gopath to find it.

Do not let the values of the Gopath and GOROOT environment variables be set to the same directory, possibly because you do not want your newly installed package to contaminate the core Go's pkg and src files.

Resources:

Goroot and gopath:http://my.oschina.net/achun/blog/134002

Only recommend this one, the other is the dog excrement.

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.