etcd undefined: resolver.BuildOption

go version go1.13.4
使用ETCD clientv3包,遇到以下错误.
使用了go mod

# 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

go.mod
image.png

google.golang.org/grpc v1.27.0

阅读 12.5k
2 个回答

终于解决啦.需要将grpc1.27.0 替换成grpc1.26.0版本.~~~~
google.golang.org/grpc v1.27.0
替换成
google.golang.org/grpc v1.26.0

具体步骤:

  1. 先删除vendor: rm -rf vendor 或手动删除
  2. 再替版本: go mod edit -require=google.golang.org/grpc@v1.26.0
  3. 下载指定版本v1.26.0: go get -u -x google.golang.org/grpc@v1.26.0
  4. 然后再go mod vendor
  5. 再运行程:go build main.go

今天遇到了同样的问题,突然对golang有所怀疑了,它的这种包管理机制真的是很annoying

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题
宣传栏