2

golang升级etcd解决 grpc兼容性问题

 2 years ago
source link: https://l1905.github.io/golang/2021/09/06/golang-etcd-grpc-incompatible/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

golang升级etcd解决 grpc兼容性问题

发表于 2021-09-06

| 分类于 golang

golang升级etcd解决 grpc兼容性问题

golang升级etcd解决 grpc兼容性问题(最新方案,不依赖replace)

目前基于milvus-go-sdk开发项目, 其依赖grpc,最低版本要求 v1.27.0, 但框架中集成的etcd依赖的grpc版本是 v1.26.0

  1. 升级grpc到v1.27.0, 导致etcd不好用
  2. 维持grpc版本在v1.26.0, 导致milvus-go-sdk不好用。

遇到了各种报错

`golang` 调用 `etcdv3` 报错 `undefined: balancer.PickOptions`
go: github.com/coreos/[email protected]: parsing go.mod etcd 3.5

使用replace方法替换, 临时本地解决, 多项目依赖 replace,治标不治本! 大部分解决方案都是基于此

一、 升级etcd到最新版本, 修改etcd调用方式

go get -u go.etcd.io/etcd/client/v3

二、 代码中修改etcd包引用方式

import "go.etcd.io/etcd/clientv3" 修改为  import "go.etcd.io/etcd/client/v3"
  1. https://chunlife.top/2021/06/17/etcd%E7%BB%88%E4%BA%8E%E8%A7%A3%E5%86%B3%E5%86%B2%E7%AA%81%E4%BA%86/

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK