go

go install 报错 cannot find package“xxx/xxx“

问题:

go install安装包的时候,如果本地环境没有对应的包,就会报错
cannot find package“xxx/xxx“。

解决:

如果可以翻墙的话可以执行go get来获取对应的包。

mkdir -p $GOPATH/src/google.golang.org/
cd $GOPATH/src/google.golang.org/
go get google.golang.org/grpc

没有工具的话,就需要把对应的包换成GitHub上的。但是从GitHub上git clone又很慢,这里有2种解决方法:
1.把GitHub的源换成Gitee
2.安装GitHub加速插件(推荐),安装后会有一个加速链接。
比如grpc:
file

cd $GOPATH/src/google.golang.org/
git clone https://github.91chi.fun/https://github.com/grpc/grpc-go.git grpc

附录

这里列举我在go install时报错缺少的包的下载链接。需要先创建对应目录,然后进行下载。

#google.golang.org/grpc
git clone https://github.91chi.fun/https://github.com/grpc/grpc-go.git grpc
#google.golang.org/genproto
git clone https://github.91chi.fun/https://github.com/googleapis/go-genproto.git genproto
#google.golang.org/protobuf
git clone https://github.91chi.fun/https://github.com/gogo/protobuf.git
#github.com/coreos
git clone https://github.91chi.fun/https://github.com/coreos/go-semver.git
#github.com/dustin
git clone https://github.91chi.fun/https://github.com/dustin/go-humanize.git
#github.com/golang/protobuf
git clone https://github.91chi.fun/https://github.com/golang/protobuf.git
#github.com/beorn7
git clone https://github.91chi.fun/https://github.com/beorn7/perks.git
#github.com/cespare
git clone https://github.91chi.fun/https://github.com/cespare/xxhash.git
#github.com/gogo
git clone https://github.91chi.fun/https://github.com/gogo/protobuf.git
#github.com/matttproud
git clone https://github.91chi.fun/https://github.com/matttproud/golang_protobuf_extensions.git
#github.com/prometheus
git clone https://github.91chi.fun/https://github.com/prometheus/client_model.git
git clone https://github.91chi.fun/https://github.com/prometheus/client_golang.git
git clone https://github.91chi.fun/https://github.com/prometheus/common.git
git clone https://github.91chi.fun/https://github.com/prometheus/procfs.git
#go.etcd.io
git clone https://github.91chi.fun/https://github.com/etcd-io/etcd.git(这里装好还会报错,需要创建v3目录,注意包的路径)
#go.uber.org/atomic
git clone https://github.91chi.fun/https://github.com/uber-go/atomic.git
#go.uber.org/multierr
git clone https://github.91chi.fun/https://github.com/uber-go/multierr.git
#go.uber.org/zap
git clone https://github.91chi.fun/https://github.com/uber-go/zap.git
#golang.org/x
git clone https://github.91chi.fun/https://github.com/golang/text.git
git clone https://github.com/golang/sys.git
git clone https://github.91chi.fun/https://github.com/golang/net.git net
分类: go
0 0 投票数
文章评分
订阅评论
提醒
guest

0 评论
最旧
最新 最多投票
内联反馈
查看所有评论

相关文章

开始在上面输入您的搜索词,然后按回车进行搜索。按ESC取消。

返回顶部
0
希望看到您的想法,请您发表评论x