简体   繁体   English

如何组织带有供应商依赖性的Go项目?

[英]How to organise a Go project with vendorised dependencies?

I'm working on a Go project that isn't a package but a service. 我正在研究一个不是软件包而是服务的Go项目。 It depends on mgo , among other things. 它取决于mgo等等。 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. 由于此服务法律应该是安全的版本,高可用性,我们已经作出vendorize的决定mgo项目内的依赖。 Due to the legal requirement we can't just rely on pulling whatever version is on origin/master for the dependency. 由于法律上的要求,我们不能仅仅依赖于拉取依赖origin/master版本上的任何版本。

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: 显然,这破坏了所有标准命令的GOPATH ,因为它不再位于GOPATH下,而是位于Git存储库中的vendor目录中:

~/src/link_tracker/
  main.go
  main_test.go
  vendor/
    src/
      labix.org/
        etc...

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. 目前,我们正在使用一个相当丑陋的Bash脚本来解决此问题,该脚本处理了许多环境变量并进行了一些符号链接,但是如果我们可以将所有这些都合并在Makefile或类似文件中,那就太好了。

What's the best/right way to organise this without losing our specifically versioned dependency of mgo ? 在不失去我们对mgo特定版本依赖的情况下,组织此活动的最佳/正确方法是什么?

您现在应该使用https://github.com/kr/godep解决此问题非常稳定,需要说明的是您的代码应位于存储库中(git,svn,mercurial等)。

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. 在labix.org的特定情况下,johnny-deps似乎要求将其托管在git托管下。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM