linux 使用 go 连接 etcd 集群时报错

问题分析

在 ubuntu 中使用 github.com/coreos/etcd/clientv3 第三方库报错,报错信息如下:

Go 复制代码
# github.com/coreos/etcd/clientv3/balancer/resolver/endpoint
/root/go/pkg/mod/github.com/coreos/etcd@v3.3.27+incompatible/clientv3/balancer/resolver/endpoint/endpoint.go:114:87: undefined: resolver.BuildOption
/root/go/pkg/mod/github.com/coreos/etcd@v3.3.27+incompatible/clientv3/balancer/resolver/endpoint/endpoint.go:115:16: target.Authority undefined (type resolver.Target has no field or method Authority)  
/root/go/pkg/mod/github.com/coreos/etcd@v3.3.27+incompatible/clientv3/balancer/resolver/endpoint/endpoint.go:118:15: target.Authority undefined (type resolver.Target has no field or method Authority)  
/root/go/pkg/mod/github.com/coreos/etcd@v3.3.27+incompatible/clientv3/balancer/resolver/endpoint/endpoint.go:182:40: undefined: resolver.ResolveNowOption
# github.com/coreos/etcd/clientv3/balancer/picker
/root/go/pkg/mod/github.com/coreos/etcd@v3.3.27+incompatible/clientv3/balancer/picker/err.go:37:53: undefined: balancer.PickOptions
/root/go/pkg/mod/github.com/coreos/etcd@v3.3.27+incompatible/clientv3/balancer/picker/roundrobin_balanced.go:55:63: undefined: balancer.PickOptions

解决办法

使用如下方式引用 etcd v3:

Go 复制代码
import (
    "go.etcd.io/etcd/client/v3"
)

注:使用 "github.com/coreos/etcd/clientv3" 方式引用时会报如上错误!

相关推荐
风曦Kisaki8 小时前
#Linux数据库管理Day06:主从同步与MaxScale读写分离
linux·运维·数据库
小楼昨夜又东风1268 小时前
使用python快速拉包
linux
Tipriest_9 小时前
ubuntu创建和更换当前swap大小
linux·运维·ubuntu
WI8LbH78810 小时前
Ubuntu 部署Harbor
linux·运维·ubuntu
researcher-Jiang11 小时前
高性能计算之MPI:第一次MPI并行程序设计练习
linux·运维·服务器
Wireless_wifi611 小时前
Why Choose IPQ9574 for Your WiFi 7 Solution
linux·人工智能·5g
MYMOTOE612 小时前
国内对标腾讯 WorkBuddy 的桌面 AI 智能体软件大全
linux
小c君tt12 小时前
linux学习笔记1
linux·笔记·学习
RisunJan12 小时前
Linux命令-read(Bash 内建读取输入)
linux