管理Go项目中的git依赖项

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

Managing Go dependencies on git

问题

我在以下目录中开发和维护我的Go项目:

PROJECT_DIR=$GOPATH/src/github.com/<USERNAME>/<PROJECT_NAME>/main.go
PROJECT_DIR=$GOPATH/src/github.com/<USERNAME>/<PROJECT_NAME>/<APP-1>
PROJECT_DIR=$GOPATH/src/github.com/<USERNAME>/<PROJECT_NAME>/<APP-2>

但是这种方式只能跟踪我的项目的更改,无法跟踪依赖项及其版本。

我想知道是否有一种自动化的方式可以克隆所有依赖项,并使用与我的项目相同的版本,而不是最新的提交?

英文:

I develop and maintain my Go project in the following directory:

PROJECT_DIR=$GOPATH/src/github.com/&lt;USERNAME&gt;/&lt;PROJECT_NAME&gt;/main.go
PROJECT_DIR=$GOPATH/src/github.com/&lt;USERNAME&gt;/&lt;PROJECT_NAME&gt;/&lt;APP-1&gt;
PROJECT_DIR=$GOPATH/src/github.com/&lt;USERNAME&gt;/&lt;PROJECT_NAME&gt;/&lt;APP-2&gt;

But this way I can only track changes in my project and I cannot track dependencies and their versions.

I was wondering if there's an automated way of cloning all the dependencies using the version that my project is using and not the latest commit?

答案1

得分: 2

你应该查看Glide

Glide提供了简化的Go项目管理、依赖管理和供应商管理。

Glide基本上会动态地改变你的$GOPATH,并将依赖项的副本保存在本地结构中,而不是传统的全局结构中,这是标准Go环境的惯例。

英文:

You should look at <a href="https://github.com/Masterminds/glide">Glide</a>.

Glide provides simplified Go project management, dependency management, and vendoring.

Glide basically changes your $GOPATH on the fly and keeps copies of your dependencies in a local structure instead of the global structure that is customary for a standard Go environment.

huangapple
  • 本文由 发表于 2014年11月22日 09:41:14
  • 转载请务必保留本文链接:https://go.coder-hub.com/27073129.html
匿名

发表评论

匿名网友

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

确定