Overcoming "no install location" Error in Go Install
Go's install command often throws an enigmatic error message: "no install location for directory outside GOPATH." This problem arises when you attempt to install a Go package located outside the GOPATH environment variable's designated workspace.
The Problem
The provided code snippet demonstrates the issue:
~/src/go-statsd-client> echo $GOPATH /Users/me/gopath ~/src/go-statsd-client> echo $GOROOT /usr/local/Cellar/go/1.1.1\ ~/src/go-statsd-client> go install go install: no install location for directory /Users/me/src/go-statsd-client outside GOPATH
The Solution: Introducing GOBIN
For OS X users, the key to resolving this issue lies in setting the GOBIN environment variable. This variable specifies the installation directory for executables created by go install.
To configure GOBIN, follow these steps:
mkdir bin export GOBIN=$GOPATH/bin
The above is the detailed content of How to Resolve the 'no install location' Error When Installing Go Packages Outside GOPATH?. For more information, please follow other related articles on the PHP Chinese website!