A leftpad fix?

agolangf · · 365 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>We probably need a community supported mirror for packages.</p> <p>Simplest way that I can think of goes something like this.</p> <p>in Gopkg.toml, add source as the community maintained mirror, like so</p> <p>```</p> <p>[[constraint]]</p> <p>name = &#34;github.com/user/package&#34;</p> <p>source = &#34;example.com/github.com/user/package&#34;</p> <p>version = &#34;1.0.0&#34;</p> <p>```</p> <p>here example.com redirects to <code>github.com/user/package</code> the first time, then caches in background and ensures all branches, commits and tags exist from that point on.</p> <p>This still leaves two use cases:</p> <ol> <li><p>What about repos that haven&#39;t been requested ever?</p></li> <li><p>What if someone gets hold of the username and updates the code?</p></li> </ol> <p>Also, how would we finance something this big?</p> <hr/>**评论:**<br/><br/>pmrsaurus: <pre><p>Isn&#39;t the fix to simply <code>vendor/</code> your dependencies?</p></pre>TheMerovius: <pre><blockquote> <p>in Gopkg.toml, add source as the community maintained mirror, like so</p> </blockquote> <p>That assumes there is a Gopkg.toml.</p> <p>I don&#39;t think that requiring upstream cooperation has any chance of resulting in a successful design.</p> <p>FWIW, I made a <a href="https://github.com/golang/go/issues/21292">proposal</a> a while back to add transparent support for mirrors to go-get. The idea is to simply put a GOPATH on a webserver (so, e.g. serve <a href="https://foobar.com/github.com/user/repo">https://foobar.com/github.com/user/repo</a>) and then have go-get make a request to <code>&lt;mirror-url&gt;/&lt;importpath&gt;</code> instead of <code>https://&lt;importpath&gt;</code>, if a flag is given.</p> <p>IMO it would be pretty simple to implement that today [edit](sorry, this was dropped) as a separate tool[/edit] and it would solve a whole lot of issues that other people are trying to solve with dep/vendoring/whatever. It would just need someone to actually do it (and be willing to host mirrors).</p></pre>jmank88: <pre><p>Related:</p> <p><a href="https://github.com/whyrusleeping/gx/issues/141" rel="nofollow">Start a conversation about ipfs/gx-style imports in dep</a></p> <p><a href="https://github.com/golang/dep/issues/286" rel="nofollow">Support for private/enterprise patterns</a></p></pre>freman: <pre><p>could just hack up a .gitconfig :D</p> <pre><code>[url &#34;https://172.31.3.81:9992/https/github.com&#34;] insteadOf = https://github.com </code></pre> <p>We&#39;re using it as a caching proxy but there&#39;s no reason you can&#39;mt</p> <pre><code>[url &#34;https://example.com/github.com/user/package&#34;] insteadOf = https://github.com/user/package </code></pre></pre>

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

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