[Help] How to manage packages in src rather than vendor?

agolangf · · 330 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>Hello,</p> <p>I have a project that consist of two different programs which are closely related to each other and hence I maintain them together under the same GOPATH &amp; repository (if that&#39;s relevant).</p> <p>My problem is, as these two programs depend on some other libraries (such as for logging) together, I&#39;d like to manage their dependencies in the src directory of the project&#39;s GOPATH, rather than using the vendor directory with <strong>dep</strong> as I currently do. Of course I can also use just <code>go get</code> but I&#39;d like to have reproducible builds, or get as near as possible by pinning the versions and so on.</p> <p>All the package managers that I could find uses the vendor directory, which is not what I want. Can someone please tell me what am I supposed to do?</p> <p>Thanks!</p> <hr/>**评论:**<br/><br/>gopher2018: <pre><p>I&#39;d just use the vendor directory. If the two projects are in the same repo, I suppose you have a directory structure like this:</p> <pre><code>GOPATH/ src/ repo/ project1/ project2/ </code></pre> <p>So, you have two options, manage dependencies on each project (1) or in the upper directory (1)</p> <p>(1):</p> <pre><code>GOPATH/ src/ repo/ project1/ vendor/ project2/ vendor/ </code></pre> <p>(2):</p> <pre><code>GOPATH/ src/ repo/ project1/ project2/ vendor/ </code></pre> <p>I think (2) would solve your use case.</p> <hr/> <p>EDIT: govendor has an <a href="https://github.com/kardianos/govendor/issues/117" rel="nofollow">open issue</a> about restoring deps on GOPATH.</p></pre>peterbourgon: <pre><p>Yeah option 2 is what you want here. Repos that represent their own GOPATH are nonstandard and fraught and shouldn’t be used outside of esoteric build environments, probably.</p></pre>

入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889

330 次点击  
加入收藏 微博
0 回复
暂无回复
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传