go get 安裝 go.etcd.io etcd clientv3 報錯

翔雲123456發表於2020-10-18

問題

直接使用

go get -u go.etcd.io/etcd/clientv3

安裝 go etcd clientv3,直接使用go get是下載最新的程式碼,沒有經過嚴格測試。

可能會遇到如下問題:

go get -u go.etcd.io/etcd/clientv3
# go.etcd.io/etcd/clientv3/balancer/picker
workspace/go_projects/src/go.etcd.io/etcd/clientv3/balancer/picker/err.go:25:9: cannot use &errPicker literal (type *errPicker) as type Picker in return argument:
	*errPicker does not implement Picker (wrong type for Pick method)
		have Pick(context.Context, balancer.PickInfo) (balancer.SubConn, func(balancer.DoneInfo), error)
		want Pick(balancer.PickInfo) (balancer.PickResult, error)
workspace/go_projects/src/go.etcd.io/etcd/clientv3/balancer/picker/roundrobin_balanced.go:33:9: cannot use &rrBalanced literal (type *rrBalanced) as type Picker in return argument:
	*rrBalanced does not implement Picker (wrong type for Pick method)
		have Pick(context.Context, balancer.PickInfo) (balancer.SubConn, func(balancer.DoneInfo), error)
		want Pick(balancer.PickInfo) (balancer.PickResult, error)

解決辦法

下載已經發布版本的source code。

已經發布的版本相對來說比較穩定,不會遇到一些奇怪的問題。

例如,v3.4.13 ,下載地址v3.4.13

下載後,解壓到$GOPATH目錄下:

tar zvxf etcd-3.4.13.tar.gz -C /home/lanyang/workspace/go_projects/src/go.etcd.io/

cd /home/lanyang/workspace/go_projects/src/go.etcd.io/
mv etcd-3.4.13/ etcd

相關文章