去获取错误 - 无法加载包 [英] go get error - can't load package

查看:88
本文介绍了去获取错误 - 无法加载包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是golang的新手,我正试图获得一个软件包,但是我收到一个奇怪的错误,似乎无法弄清楚问题所在。

I am new to golang and I am trying to get a package but I get a strange error and can't seem to figure out what the problem is?

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"


推荐答案

在两个不同的导入路径上获取。新路径

go get golang.org/x/oauth2

和旧路径

and the old path

go get github.com/golang/oauth2

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

This confuses the Go tool chain. Consistently use the new import path

go get golang.org/x/oauth2

这篇关于去获取错误 - 无法加载包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆