Go get: no install location for directory

~/src/go-statsd-client> echo $GOPATH
~/src/go-statsd-client> echo $GOROOT
~/src/go-statsd-client> go install
go install: no install location for directory /Users/me/src/go-statsd-client outside GOPATH

When you provide no arguments to go install, it defaults to attempting to install the package in the current directory. The error message is telling you that it cannot do that, because the current directory isn’t part of your $GOPATH.

You can either:

  • Define $GOPATH to your $HOME (export GOPATH=$HOME).
  • Move your source to within the current $GOPATH (mv ~/src/go-statsd-client /User/me/gopath).

After either, going into the go-statsd-client directory and typing go install will work, and so will typing go install go-statsd-client from anywhere in the filesystem. The built binaries will go into $GOPATH/bin.

As an unrelated suggestion, you probably want to namespace your package with a domain name, to avoid name clashing (e.g. github.com/you/go-statsd-client, if that’s where you hold your source code).