Go install fails with error: no install location for directory xxx outside GOPATH
For any OS X users and future me, you also need to set GOBIN
to avoid this confusing message on install and go get
mkdir bin
export GOBIN=$GOPATH/bin
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).