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
- Path=c:\go\bin; other settings;
2. Set Goroot, this good understanding, directly set into C:\Go can
[JavaScript]View Plaincopy
- Goroot=c:\go
3. Set Gopath, this is hard to understand, I try:
[Python]View Plaincopy
- 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
- gopath=; #就是等于一个分号 (;), go get package start can run, no error, and finally error, said $gopath not set
- 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
- 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.