undefined: resolver.BuildOption
undefined: resolver.BuildOption
在用clientv3连接etcd时。
遇到一个坑,略记录一下,其报错如下:
C:\Users\anmut\go\pkg\mod\github.com\coreos\etcd@v3.3.22+incompatible\clientv3\balancer\resolver\endpoint\endpoint.go:114:78: undefined: resolver.BuildOption C:\Users\anmut\go\pkg\mod\github.com\coreos\etcd@v3.3.22+incompatible\clientv3\balancer\resolver\endpoint\endpoint.go:182:31: undefined: resolver.ResolveNowOption # github.com/coreos/etcd/clientv3/balancer/picker C:\Users\anmut\go\pkg\mod\github.com\coreos\etcd@v3.3.22+incompatible\clientv3\balancer\picker\err.go:37:44: undefined: balancer.PickOptions C:\Users\anmut\go\pkg\mod\github.com\coreos\etcd@v3.3.22+incompatible\clientv3\balancer\picker\roundrobin_balanced.go:55:54: undefined: balancer.PickOptions
查了下
大概是说原因是google.golang.org/grpc 1.26后的版本是不支持clientv3的。
也就是说要把这个改成1.26版本的就可以了。
具体操作方法是在go.mod里加上:
replace google.golang.org/grpc => google.golang.org/grpc v1.26.0
也就是这样:
接着跑就会发现成功了。不会出错了。你看: