英文:
"glide get" and "go get" install different versions
问题
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论