正确的 Golang 销售工具

Right Golang vendoring tool

我希望我的所有依赖项与我在 Go 中的项目一起受到源代码控制。

我可以看到有两个主要工具可以完成这项工作(Dep 和 Glide)。

问题是 Dep States 在其页面上:

dep was the "official experiment." The Go toolchain, as of 1.11, has (experimentally) adopted an approach that sharply diverges from dep. As a result, we are continuing development of dep, but gearing work primarily towards the development of an alternative prototype for versioning behavior in the toolchain.

另一方面,Glide 似乎没有任何 activity 在其回购协议中。

我想知道你们"best"处理这个问题的方式是什么?

我真的很喜欢 Go 和它的哲学,但我必须承认依赖管理真的很混乱。

我不是 Golang 专家所以我可能是错的,但根据 golang/go wiki:

For any production workloads, use dep, or migrate to it if you have not done so already.

The proposal has been accepted and vgo was merged into the Go tree in version 1.11.

You will be able to experiment with the module workflow from Go 1.11 as it is included as an experiment in this release.

所以看起来模块支持目前处于实验模式,在 vgo 完全集成之前,您应该对任何生产就绪代码坚持使用 dep。

请注意,如 in this article 所述,dep 有其自身的一系列问题,主要围绕版本冲突和传递依赖项管理。在 vgo 被认为可以生产之前,我的理解是您需要自己处理这些问题。

编辑:添加了有关 dep 问题的部分。

根据我的经验,我的解决方案是使用 go modules 来管理依赖项。我在安装依赖项时遇到了 dep 的一些问题,我花了很多精力来修复它。所以我切换到 go 模块,它在生产环境中按预期工作。模块是 Go 中的一个 built-in 特性,它在 Go 1.11 中引入,从 Go 1.13 开始,模块模式将成为所有开发的默认模式。

Go 模块使安装依赖项变得更快、更容易。使用模块,所有依赖项将在 go.mod 文件中列出:

module example.com/hello

require (
    github.com/some/dependency v1.2.3
    github.com/another/dependency/v4 v4.0.0
)

如何获得依赖:

go get github.com/some/dependency@v1.2.3