【go】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
【go】etcd undefined: resolver.BuildOption

google.golang.org/grpc v1.27.0

回答

终于解决啦.需要将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/[email protected]

  3. 下载指定版本v1.26.0: go get -u -x google.golang.org/[email protected]

  4. 然后再go mod vendor

  5. 再运行程:go build main.go

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

以上是 【go】etcd undefined: resolver.BuildOption 的全部内容, 来源链接: utcz.com/a/106873.html

回到顶部