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

阅读 3.4k
评论 2月16日提问
    2 个回答
    百里
    • 183

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