golang中使用 github.com/coreos/etcd/clientv3 第三方库报错

使用go连接etcd,需要下载第三方库,即:go get go.etcd.io/etcd/clientv3 ,过程中报错如下:

github.com/coreos/etcd/clientv3/balancer/resolver/endpoint
vendor\github.com\coreos\etcd\clientv3\balancer\resolver\endpoint\endpoint.go:114:78: undefined: resolver.BuildOption
vendor\github.com\coreos\etcd\clientv3\balancer\resolver\endpoint\endpoint.go:182:31: undefined: resolver.ResolveNowOption
github.com/coreos/etcd/clientv3/balancer/picker
vendor\github.com\coreos\etcd\clientv3\balancer\picker\err.go:37:44: undefined: balancer.PickOptions
vendor\github.com\coreos\etcd\clientv3\balancer\picker\roundrobin_balanced.go:55:54: undefined: balancer.PickOptions

原因:需要将grpc1.27.1 替换成grpc1.26.0版本
解决:此时可以点开go.mod文件,将google.golang.org/grpc v1.27.1 *// indirect*更改为 google.golang.org/grpc v1.26.0 *// indirect*。

然后再go get即可。

上一篇:负载均衡的原理


下一篇:MongoDB疑难解析:为什么升级之后负载升高了?