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
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

柠是柠檬的檬

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值