Search code examples
gogopath

Go no install location for directory outside GOPATH error when run "go get"


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


Solution

  • According with this link: github.com/golang/go/wiki/SettingGOPATH

    Is needed to set GOBIN path in bash file: export GOBIN=$GOPATH/bin