英文:
Go no install location for directory outside GOPATH error when run "go get"
问题
以下是翻译好的内容:
简单的Go项目,有一个外部依赖:
import (
"fmt"
"html"
"log"
"net/http"
"github.com/gorilla/mux"
)
我的路径在其他任务(如运行、构建等)中正常工作:
GOPATH="/home/racar/go"
但是当我尝试使用"go get"命令获取外部包时,我遇到了这个错误:
"go install: no install location for directory... outside GOPATH"
编辑:
我在 ~/.bashrc 中设置了我的 PATH:export PATH=$PATH:$GOROOT/bin:$GOPATH/bin
英文:
Simple Go project, with a external dependence:
import (
"fmt"
"html"
"log"
"net/http"
"github.com/gorilla/mux"
)
My path working fine for other tasks like run, build, etc.:
GOPATH="/home/racar/go"
But when I try to get a external package with "go get" command, I got this error:
> "go install: no install location for directory... outside GOPATH"
Edit:
I have set my PATH in ~/.bashrc: export PATH=$PATH:$GOROOT/bin:$GOPATH/bin
答案1
得分: 12
根据这个链接:github.com/golang/go/wiki/SettingGOPATH
需要在bash文件中设置GOBIN路径:export GOBIN=$GOPATH/bin
英文:
According with this link: github.com/golang/go/wiki/SettingGOPATH
Is needed to set GOBIN path in bash file: export GOBIN=$GOPATH/bin
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论