Programing

go get으로 "인식 할 수없는 가져 오기 경로"

crosscheck 2020. 9. 19. 09:11
반응형

go get으로 "인식 할 수없는 가져 오기 경로"


을 (를) 설치하려고하는데 web.go실행중인 go get github.com/hoisie/web반환

package bufio: unrecognized import path "bufio"
package bytes: unrecognized import path "bytes"
package crypto/rand: unrecognized import path "crypto/rand"
package crypto/sha1: unrecognized import path "crypto/sha1"
package crypto/tls: unrecognized import path "crypto/tls"
package encoding/base64: unrecognized import path "encoding/base64"
package encoding/binary: unrecognized import path "encoding/binary"
package encoding/json: unrecognized import path "encoding/json"
package errors: unrecognized import path "errors"
package fmt: unrecognized import path "fmt"

그리고 이것은 다른 것을 반환하기 전에 다양한 패키지로 잠시 동안 계속됩니다. go env나에게 준다 :

GOARCH="amd64"
GOBIN="/usr/local/go/bin"
GOCHAR="6"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH=""
GORACE=""
GOROOT="/home/me/go"
GOTOOLDIR="/home/me/go/pkg/tool/linux_amd64"
TERM="dumb"
CC="gcc"
GOGCCFLAGS="-g -O2 -fPIC -m64 -pthread"
CXX="g++"
CGO_ENABLED="1"

어떻게 설치할 수 web.go있습니까? go get(대신 go install) 사용 은 github 페이지의 README에 있습니다. 내 Go 버전은 go version go1.2 linux/amd64.


문제는 유효하지 않은 GOROOT.

Go를 설치 한 것 같습니다 /usr/local/go.
따라서 GOROOT경로를 /usr/local/go/bin.

작업 공간 (GOPATH)을 /home/me/go.

문제를 해결할 수 있습니다.
여기에있는 bash 프로필의 맨 아래에 이것을 추가하십시오 =>$HOME/.profile

export GOROOT=/usr/local/go
export GOPATH=$HOME/go
export PATH=$PATH:$GOROOT/bin

의 이전 참조를 제거해야합니다 GOROOT.

그런 다음 web.go를 다시 설치하십시오.

그래도 작동하지 않으면 Ubuntu에서 Go를 설치하십시오.

sudo apt-get install golang

비디오 자습서 : http://www.youtube.com/watch?v=2PATwIfO5ag


brewOSX 10.11에 Go with 설치 했고 다음과 같이 설정 GOROOT해야했습니다.

/usr/local/Cellar/go/1.5.1/libexec

(물론이 경로의 버전을 가지고있는 go 버전으로 바꾸십시오)

Brew는 gotool을 속이는 심볼릭 링크를 사용합니다. 따라서 링크 집을 따르십시오.


우분투 14.04의 이전 버전 (이전 PPA에서 설치됨)에서 최신 (1.2.1) 기본 패키지로 이동 한 후에도 똑같은 문제가 발생했습니다.

첫 번째 단계는 기존 go를 제거하는 것이 었습니다.

sudo apt-get purge golang*

다음 경고를 출력합니다.

dpkg: warning: while removing golang-go, directory '/usr/lib/go/src' not empty so not removed
dpkg: warning: while removing golang-go.tools, directory '/usr/lib/go' not empty so not removed

It looks like removing go leaves some files behind, which in turn can confuse newer install. More precisely, installation itself will complete fine, but afterwards any go command, like "go get something" gives those "unrecognized import path" errors.

All I had to do was to remove those dirs first, reinstall golang, and all works like a charm (assuming you also set GOPATH)

# careful!
sudo rm -rf /usr/lib/go /usr/lib/go/src
sudo apt-get install golang-go golang-go.tools

Because GFW forbidden you to access golang.org ! And when i use the proxy , it can work well.

you can look at the information using command go get -v -u golang.org/x/oauth2


$ unset GOROOT worked for me. As most answers suggest your GOROOT is invalid.


I had the same problem on MacOS 10.10. And I found that the problem caused by OhMyZsh shell. Then I switched back to bash everything went ok.

Here is my go env

bash-3.2$ go env
GOARCH="amd64"
GOBIN=""
GOCHAR="6"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/bis/go"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fno-common"
CXX="clang++"
CGO_ENABLED="1

I had the same issue after having upgraded go1.2 to go1.4.

I renamed src to _src in my GOPATH then did a go get -v

It worked then I deleted _src.

Hope it helps.


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

The most common causes are:
1. An incorrectly configured GOROOT
OR
2. GOPATH is not set

참고URL : https://stackoverflow.com/questions/20458796/unrecognized-import-path-with-go-get

반응형