“glide get”和“go get”安装不同的版本。

huangapple go评论69阅读模式
英文:

"glide get" and "go get" install different versions

问题

我使用ginkgo作为测试工具,glide作为包管理器。

ginkgo要求我们安装一个二进制文件来自动生成测试文件。据我所知,glide不支持安装二进制文件。所以,我最终使用go get命令安装了二进制文件和其源代码文件。

问题在于,glide会安装所有通过扫描Go文件解析出来的包。这意味着ginkgo的源代码也会被安装。在编译过程中,vendor目录中的包具有优先级。这导致了使用了$GOPATH/bin目录下的二进制文件,同时使用了vendor目录中的源代码文件。
而且,似乎go get命令从主分支获取文件,而glide命令获取的是最新发布版本。因此,由二进制文件生成的测试文件与由glide安装的源代码文件不兼容。

有没有办法阻止glide安装某些特定的包?
或者有没有其他更好的方法?

英文:

I use ginkgo for the test tool, and glide for the package manager.

ginkgo requires that we install a binary to generate test files automatically. glide, to the best of my knowledge, does not support the installation of binaries. So, I ended up using go get to install the binary, along with its source files.

A problem is that glide installs all the packages that it resolves by scanning the go files. This means that the source files of ginkgo are also installed.
During the compilation, the packages in vendor directory is prioritized. So this causes the situation where binary from $GOPATH/bin is used, and source files from vendor directory are used.
And it seems that go get fetches files from master branch, where as glide fetches the latest released version. So the test files that are generated by the binary is not compatible with the source files installed by glide.

Is there any way to prevent glide from installing some specific packages?
Or are there any other better ways?

答案1

得分: 2

使用Glide,您可以指定要安装的软件包的特定版本。这是在glide.yaml文件中完成的。

提示:版本可以是与版本控制系统相关的任何内容,可以是可以检出的任何内容,也可以是可以由github.com/Masterminds/semver软件包解析的语义版本约束。例如,对于Git,这可以是分支、标签或哈希值。这取决于版本控制系统支持的内容。

package: github.com/YOUR/PACKAGE
import:
  - package: github.com/onsi/ginkgo/ginkgo
    version: master
    repo: git@github.com:onsi/ginkgo.git

这将下载最新的主分支提交。

这里可以找到有关使用Glide进行版本控制的更多信息。

英文:

With glide you can specify a certain version of the package you want to install. This is done in the glide.yaml

> TIP: The version is either VCS dependent and can be anything that can
> be checked out or a semantic version constraint that can be parsed by
> the github.com/ Masterminds/semver package. For example, with Git this
> can be a branch, tag, or hash. This varies and depends on what's
> supported in the VCS.

package: github.com/YOUR/PACKAGE
import:
  - package: github.com/onsi/ginkgo/ginkgo
    version: master
    repo: git@github.com:onsi/ginkgo.git

This will download the latest master commit.

Here are further information about versioning with glide.

huangapple
  • 本文由 发表于 2017年6月18日 14:54:04
  • 转载请务必保留本文链接:https://go.coder-hub.com/44612487.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定