echo $GOPATH
/Users/me/go/
In go the code below outputs /Users/me/go:
. Notice :
package main
import "os"
import "fmt"
func main(){
p := os.Getenv("GOPATH")
fmt.Println(p)
}
However I've tested it on linux and the dots (:
) are replaced by a slash ( which I think is the correct form so we have /Users/me/go/
. I'm wondering why is this inconsistency and if it's actually a bug.
System Info:
go version
go version go1.3 darwin/amd64
OS: OSX 10.7.5
The GOPATH
environment variable is a list of paths. On Unix-like operating systems, the value is a colon-separated string of paths. For example,
/Users/me/go/:/Users/all/go/
or
/Users/me/go:/Users/all/go:
The Go path is used to resolve import statements. It is implemented by and documented in the go/build package.
The GOPATH environment variable lists places to look for Go code. On Unix, the value is a colon-separated string. On Windows, the value is a semicolon-separated string. On Plan 9, the value is a list.
Go searches each directory listed in GOPATH to find source code, but new packages are always downloaded into the first directory in the list.