简体   繁体   English

三个etcd-go包有什么区别?

[英]What's the difference between three etcd-go package?

There are three different etcd-go package, they are:有三种不同的 etcd-go 包,它们是:

  1. github.com/coreos/etcd github.com/coreos/etcd
  2. go.etcd.io/etcd go.etcd.io/etcd
  3. go.etcd.io/etcd/v3 go.etcd.io/etcd/v3

According to the commit here , all the official codes have changed the package from go.etcd.io/etcd to go.etcd.io/etcd/v3 with following messages:根据这里的提交,所有官方代码都将包从go.etcd.io/etcd更改为go.etcd.io/etcd/v3并显示以下消息:

This change makes the etcd package compatible with the existing Go ecosystem for module versioning.此更改使 etcd 包与现有的 Go 生态系统兼容,以进行模块版本控制。

But I can't get the go.etcd.io/etcd/v3 package by go get command.但是我无法通过go get命令获取go.etcd.io/etcd/v3包。

So what's the difference between these three etcd-go packages?那么这三个etcd-go包有什么区别呢? And how to use them properly.以及如何正确使用它们。

Thanks in advance.提前致谢。

There is a known issue in the client v3.4 with go get failing.客户端v3.4存在一个go get失败的已知问题。 See this issue: https://github.com/etcd-io/etcd/issues/11154看到这个问题: https : //github.com/etcd-io/etcd/issues/11154

Although the issue has been closed because it is (supposedly) fixed in v3.5 , that version is not yet released (when writing this).尽管该问题已被关闭,因为它(据说)已在v3.5修复,但该版本尚未发布(在撰写本文时)。

There are a few workarounds posted the issue above.上面发布了一些解决方法。 The one that worked for us was to circumvent the incorrectly implemented go module of etcd and pin the version to a commit directly in our go.mod file:对我们etcd是绕过etcd错误实现的 go 模块, etcd版本直接固定到我们的 go.mod 文件中:

require go.etcd.io/etcd v0.0.0-20200520232829-54ba9589114f

The clientv3 is then imported with:然后使用以下命令导入clientv3

import "go.etcd.io/etcd/clientv3"

The document for no.2 in the question points to this link问题中2号文件指向此链接

https://pkg.go.dev/go.etcd.io/etcd/clientv3?tab=doc https://pkg.go.dev/go.etcd.io/etcd/clientv3?tab=doc

The package has below version and commit hash该软件包具有以下版本和提交哈希

v0.5.0 (ae9734e) v0.5.0 (ae9734e)

The document for no.3 in the question points to this link问题中3号文件指向此链接

https://pkg.go.dev/go.etcd.io/etcd/v3/clientv3?tab=doc https://pkg.go.dev/go.etcd.io/etcd/v3/clientv3?tab=doc

The package has below version and commit hash该软件包具有以下版本和提交哈希

v3.3.0 (c20cc05) v3.3.0 (c20cc05)

etcd would have made a breaking change in latest release and hence changed the module path to differ from the old path. etcd 会在最新版本中进行重大更改,因此将模块路径更改为与旧路径不同。 This is a convention recommended in official Golang blog.这是 Golang 官方博客推荐的约定。

Read this blog.阅读此博客。 https://blog.golang.org/v2-go-modules Even though both of them point to the same repo, you have to import these versions differently like below. https://blog.golang.org/v2-go-modules尽管它们都指向同一个 repo,但您必须以不同的方式导入这些版本,如下所示。 You can find the correct module path from go.mod file in the root of the repository.您可以从存储库根目录中的 go.mod 文件中找到正确的模块路径。

import "go.etcd.io/etcd/clientv3"导入“go.etcd.io/etcd/clientv3”

import "go.etcd.io/etcd/v3/clientv3"导入“go.etcd.io/etcd/v3/clientv3”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM