Golang etcd/clientv3报错: etcd undefined: resolver.BuildOption
故障描述
golang版本
go version
go version go1.14 windows/amd64
包管理器go.mod
module goAgent
go 1.14
require (
github.com/Shopify/sarama v1.26.1
github.com/coreos/etcd v3.3.18+incompatible // indirect
github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf // indirect
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f // indirect
github.com/go-ini/ini v1.52.0
github.com/gogo/protobuf v1.3.1 // indirect
github.com/google/uuid v1.1.1 // indirect
github.com/hpcloud/tail v1.0.0
go.etcd.io/etcd v3.3.18+incompatible
go.uber.org/zap v1.14.0 // indirect
google.golang.org/grpc v1.27.1 // indirect
gopkg.in/fsnotify.v1 v1.4.7 // indirect
gopkg.in/ini.v1 v1.52.0
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
)
在安装go get go.etcd.io/etcd/clientv3时出错
错误信息:
# github.com/coreos/etcd/clientv3/balancer/resolver/endpoint
../../pkg/mod/github.com/coreos/etcd@v3.3.18+incompatible/clientv3/balancer/resolver/endpoint/endpoint.go:114:78: undefined: resolver.BuildOption
../../pkg/mod/github.com/coreos/etcd@v3.3.18+incompatible/clientv3/balancer/resolver/endpoint/endpoint.go:182:31: undefined: resolver.ResolveNowOption
# github.com/coreos/etcd/clientv3/balancer/picker
../../pkg/mod/github.com/coreos/etcd@v3.3.18+incompatible/clientv3/balancer/picker/err.go:37:44: undefined: balancer.PickOptions
../../pkg/mod/github.com/coreos/etcd@v3.3.18+incompatible/clientv3/balancer/picker/roundrobin_balanced.go:55:54: undefined: balancer.PickOptions
解决方法
将grpc版本替换成v1.26.0版本
1. 修改依赖为v1.26.0
go mod edit -require=google.golang.org/grpc@v1.26.0
下载v1.26.0版本的grpc
go get -u -x google.golang.org/grpc@v1.26.0
etcd连接成功!