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

阅读 5.8k
评论
    2 个回答
    • 196

    终于解决啦.需要将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

        撰写回答

        登录后参与交流、获取后续更新提醒

        相似问题
        推荐文章