Edit: since you meant GOPATH, see fasmat answer (upvoted)
As mentioned in " How do I find my package ? , you need to put the xxx package in the xxx directory.
See Go to Language Specification :
package math
A set of files that have the same PackageName form for implementing the package.
An implementation may require that all source files for a package be in the same directory.
The code organization mentions:
When creating a program that imports the widget package, the go command searches for src/pkg/widget inside the Go root, and then - if the source of the package is not found there, it searches for src/widget inside each workspace in order.
("workspace" is a path entry in your GOPATH : this variable can refer to several paths for your " src, bin, pkg ")
(Original answer)
You should also set GOPATH to ~ / go, not GOROOT , as shown in " How to write a jump code ."
The Go path is used to enable import statements. It is implemented and documented in the go / build package.
The GOPATH environment GOPATH lists the places to search for Go code.
On Unix, a value is a colon delimited string.
On Windows, the value is a comma delimited string.
In Plan 9, a value is a list.
This is different from GOROOT :
Go binary distributions assume that they will be installed in /usr/local/go (or c:\Go under Windows), but they can be installed elsewhere.
If you do this, you will need to set the GOROOT environment GOROOT to this directory when using the Go tools.
VonC Nov 03 '12 at 22:30 2012-11-03 22:30
source share