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:
$GOPATH
to your $HOME (export GOPATH=$HOME
).$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).
You are using go install on a directory outside the GOPATH folder. Set your GOBIN env variable, or move src folder inside GOPATH.
GOPATH/
bin/
src/
go-statsd-client/
More info: GO BUILD Source code, line 296
You need to setup both GOPATH
and GOBIN
. Make sure you have done the following (please replace ~/go
with your preferred GOPATH
and subsequently change GOBIN
). This is tested on Ubuntu 16.04 LTS
.
export GOPATH=~/go
mkdir ~/go/bin
export GOBIN=$GOPATH/bin
The selected answer did not solve the problem for me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With