当运行”go get”命令时,出现”Go no install location for directory outside GOPATH”错误。

huangapple go评论124阅读模式
英文:

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

huangapple
  • 本文由 发表于 2017年6月24日 01:11:59
  • 转载请务必保留本文链接:https://go.coder-hub.com/44726753.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定