I have the error:
go install: no install location for directory /Users/xwilly/Dropbox/go/project/src outside GOPATH
I\'m using go version 1.1
Command go
GOPATH environment variable
Each directory listed in
GOPATHmust have a prescribed structure:The
src/directory holds source code. The path below 'src' determines the import path or executable name.The
pkg/directory holds installed package objects. As in the Go tree, each target operating system and architecture pair has its own subdirectory ofpkg(pkg/GOOS_GOARCH).If
DIRis a directory listed in theGOPATH, a package with source in DIR/src/foo/bar can be imported as "foo/bar" and has its compiled form installed to "DIR/pkg/GOOS_GOARCH/foo/bar.a".The
bin/directory holds compiled commands. Each command is named for its source directory, but only the final element, not the entire path. That is, the command with source inDIR/src/foo/quuxis installed into DIR/bin/quux, notDIR/bin/foo/quux. Thefoo/is stripped so that you can addDIR/binto yourPATHto get at the installed commands. If theGOBINenvironment variable is set, commands are installed to the directory it names instead ofDIR/bin.Here's an example directory layout:
GOPATH=/home/user/gocode /home/user/gocode/ src/ foo/ bar/ (go code in package bar) x.go quux/ (go code in package main) y.go bin/ quux (installed command) pkg/ linux_amd64/ foo/ bar.a (installed package object)
Your directory structure is wrong. You are trying to install a command (package main). It should be in a source directory named after your command. See the quux command above.
In your case, assume your command is going to be named billy.
$ mkdir -p /Users/xwilly/Dropbox/go/project/src/billy
which is inside your GOPATH. Move your test.go file to this directory. Run
$ go install billy
The command billy should, unless you have set GOBIN, be installed in the
/Users/xwilly/Dropbox/go/project/bin
directory inside your GOPATH, which should be in your PATH.