英文:
How to organise a Go project with vendorised dependencies?
问题
我正在处理一个Go项目,它不是一个包,而是一个服务。它依赖于mgo
和其他一些东西。由于这个服务在法律上要求具有安全版本和高可用性,我们决定将mgo
依赖项嵌入到项目中。由于法律要求,我们不能仅仅依赖于从origin/master
拉取的任意版本的依赖项。
显然,这会破坏所有标准命令的GOPATH
,因为它不再位于GOPATH
下,而是在Git仓库的vendor
目录中:
~/src/link_tracker/
main.go
main_test.go
vendor/
src/
labix.org/
等等...
我们目前正在使用一个相当丑陋的Bash脚本来解决这个问题,它会修改许多环境变量并进行一些符号链接,但如果我们能将所有这些都整合到一个Makefile或类似的东西下面会更好。
在不丢失我们特定版本的mgo
依赖项的情况下,最好/正确的组织方式是什么?
英文:
I'm working on a Go project that isn't a package but a service. It depends on mgo
, among other things. Because this service is legally supposed to be securely versioned and highly available we've made the decision to vendorize the mgo
dependency within the project. Due to the legal requirement we can't just rely on pulling whatever version is on origin/master
for the dependency.
Obviously this breaks our GOPATH
for all standard commands as it's no longer living under GOPATH
but in a vendor
directory within the Git repository:
<pre><code>~/src/link_tracker/
main.go
main_test.go
vendor/
src/
labix.org/
etc...
</code></pre>
We're currently working around this using a fairly ugly Bash script that mangle lots of environment variables and does some symlinking, but it'd be nice if we could consolidate all this under a Makefile or similar.
What's the best/right way to organise this without losing our specifically versioned dependency of mgo
?
答案1
得分: 1
你现在应该使用https://github.com/kr/godep来解决这个问题,它非常稳定。需要注意的是,你的代码应该在一个代码库(如git、svn、mercurial等)中。
英文:
You should use https://github.com/kr/godep to solve this problem now is very stable, the thing to have on account is that your code should be on a repository(git, svn, mercurial , among others).
答案2
得分: 0
我一直在使用两个类似目标的工具:
你应该看看是否可以使用其中一个而不是自己编写。在labix.org的情况下,johnny-deps似乎要求使用git托管。
英文:
The two tools I've been playing with (for similar goals) are:
You should probably see if you can use one of them instead of rolling your own. In the particular case of the labix.org stuff, johnny-deps appears to require things to be git-hosted.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论