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/[email protected]+incompatible/clientv3/balancer/resolver/endpoint/endpoint.go:114:87: undefined: resolver.BuildOption
/root/go/pkg/mod/github.com/coreos/[email protected]+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/[email protected]+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/[email protected]+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/[email protected]+incompatible/clientv3/balancer/picker/err.go:37:53: undefined: balancer.PickOptions
/root/go/pkg/mod/github.com/coreos/[email protected]+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" 方式引用时会报如上错误!

相关推荐
北极象1 分钟前
Go语言处理HTTP下载中EOFFailed
开发语言·http·golang
麟城Lincoln21 分钟前
【Linux笔记】nfs网络文件系统与autofs(nfsdata、autofs、autofs.conf、auto.master)
linux·网络·笔记·nfs·autofs
程序员爱钓鱼28 分钟前
匿名函数与闭包(Anonymous Functions and Closures)-《Go语言实战指南》原创
后端·golang
***似水流年***39 分钟前
Linux任务管理与守护进程
linux·运维·服务器
python算法(魔法师版)1 小时前
.NET NativeAOT 指南
java·大数据·linux·jvm·.net
正经教主1 小时前
【基础】Windows开发设置入门4:Windows、Python、Linux和Node.js包管理器的作用和区别(AI整理)
linux·windows·python·包管理器
Zfox_2 小时前
RPM 包制作备查 &SRPM 包编译
linux·rpm·srpm
言之。2 小时前
Go 语言中接口类型转换为具体类型
开发语言·后端·golang
Excuse_lighttime2 小时前
JVM 机制
java·linux·jvm
YOYO--小天3 小时前
4G和5G模块的使用
linux·嵌入式硬件·5g