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


問題

直接使用

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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM