"go install: no install location for directory outside GOPATH" Error Resolved
When attempting to install Go projects located outside the GOPATH, developers often encounter the error "go install: no install location for directory outside GOPATH." This issue occurs because Go looks for the environment variable path $GOBIN by default. To resolve this issue, one can either set $GOBIN to $GOPATH/bin or add $GOBIN to the OS search path.
To achieve the first method, run the following command:
$ export GOBIN=$GOPATH/bin
The second method requires adding $GOBIN to the OS search path. Execute the following command:
$ export PATH=$PATH:$GOBIN
After implementing either of these steps, the "go install" command can be executed outside the GOPATH without encountering the error.
The above is the detailed content of How to Fix 'go install: no install location for directory outside GOPATH'?. For more information, please follow other related articles on the PHP Chinese website!