How to Fix 'go install: no install location for directory outside GOPATH'?

Mary-Kate Olsen
Release: 2024-11-10 13:59:03
Original
242 people have browsed it

How to Fix

"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
Copy after login

The second method requires adding $GOBIN to the OS search path. Execute the following command:

$ export PATH=$PATH:$GOBIN
Copy after login

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!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template