得到错误 - 无法加载包

时间:2014-12-07 15:09:12

标签: oauth go oauth-2.0

我是golang的新手,我正试图获得一个软件包,但是我发现了一个奇怪的错误,似乎无法弄清问题是什么?

padlar@padlar:~/workspace-go$ echo $GOPATH
/home/padlar/workspace-go

padlar@padlar:~/workspace-go$ go get golang.org/x/oauth2
padlar@padlar:~/workspace-go$ ls ~/workspace-go/src/golang.org/x/oauth2/
    AUTHORS            google/            jwt_test.go        README.md          
    CONTRIBUTORS       internal/          LICENSE            transport.go       
    example_test.go    jws/               oauth2.go          transport_test.go  
    .git/              jwt.go             oauth2_test.go     .travis.yml        

padlar@padlar:~/workspace-go$ ls ~/workspace-go/pkg/linux_amd64/golang.org/x/oauth2
oauth2/   oauth2.a  
padlar@padlar:~/workspace-go$ ls ~/workspace-go/pkg/linux_amd64/golang.org/x/oauth2/
internal.a  jws.a
padlar@padlar:~/workspace-go$ go get github.com/golang/oauth2
can't load package: package github.com/golang/oauth2: code in directory /home/padlar/workspace-go/src/github.com/golang/oauth2 expects import "golang.org/x/oauth2"

1 个答案:

答案 0 :(得分:15)

您在两个不同的导入路径上使用go get。新路径,

go get golang.org/x/oauth2

和旧路径

go get github.com/golang/oauth2

这会混淆Go工具链。始终如一地使用新的导入路径

go get golang.org/x/oauth2