“unrecognized import path” with go get

后端 未结 9 768
你的背包
你的背包 2020-12-07 18:00

I\'m trying to install a web.go, but running go get github.com/hoisie/web returns

package bufio: unrecognized import path \"bufio\"         


        
9条回答
  •  执笔经年
    2020-12-07 18:39

    I encountered this issue when installing a different package, and it could be caused by the GOROOT and GOPATH configuration on your PATH. I tend not to set GOROOT because my OS X installation handled it (I believe) for me.

    1. Ensure the following in your .profile (or wherever you store profile configuration: .bash_profile, .zshrc, .bashrc, etc):

      export GOPATH=$HOME/go
      export PATH=$PATH:$GOROOT/bin
      
    2. Also, you likely want to unset GOROOT, as well, in case that path is also incorrect.

    3. Furthermore, be sure to clean your PATH, similarly to what I've done below, just before the GOPATH assignment, i.e.:

      export PATH=$HOME/bin:/usr/local/bin:$PATH
      export GOPATH=$HOME/go
      export PATH=$PATH:$GOROOT/bin
      
    4. Then, source <.profile> to activate

    5. retry go get

提交回复
热议问题