How to create micropackages with gists

blov · · 543 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>If you ever had the necessity of sharing code fast, you can use gists.</p> <p>You just need to create a .go file an save the gist. Then use that repository as source.</p> <p>For example: <a href="https://gist.github.com/guillermo/0eb7e53fa687acbf05ea">https://gist.github.com/guillermo/0eb7e53fa687acbf05ea</a></p> <p>You can import that in your code</p> <pre><code>import ( . &#34;gist.github.com/0eb7e53fa687acbf05ea.git&#34; ) </code></pre> <p>Or even use it with <a href="https://godoc.org/gist.github.com/0eb7e53fa687acbf05ea.git">godocs.org</a></p> <hr/>**评论:**<br/><br/>divan0: <pre><p>Actually, some people use gists as packages in the real world code. See Go-Package-Store for example, where packages are named gist7480523, gist7802150 and so on. It&#39;s absolutely unreadable and scary. <a href="https://github.com/shurcooL/Go-Package-Store/blob/master/main.go">https://github.com/shurcooL/Go-Package-Store/blob/master/main.go</a></p></pre>guillermooo: <pre><p>Hello.</p> <p>I found the same example looking for gists being used in packages, but if you look carefully, that packages is not using gist at all. Is just the author that, automatically or manually, commit some gists in the code. </p></pre>xlab_is: <pre><p>Sadly we can&#39;t use URL shorteners here. <a href="http://github.com/xlab/gitio" rel="nofollow">http://github.com/xlab/gitio</a> can help me get links like <a href="http://git.io/xlab_ping.git" rel="nofollow">http://git.io/xlab_ping.git</a> that resolve with 302 into <a href="https://gist.github.com/xlab/df49fae54b7c6ec03f71.git" rel="nofollow">https://gist.github.com/xlab/df49fae54b7c6ec03f71.git</a> but the latter can be subject for go get and the former can&#39;t. I&#39;m not sure if this is a bug or not.</p> <p>So, using &#34;0eb7e53fa687acbf05ea.git&#34; or &#34;df49fae54b7c6ec03f71.git&#34; will drive your gopher colleagues nuts.</p></pre>guillermooo: <pre><p>The readability issue is there, and I am ok with that. </p> <p>This is not meant to replace traditional packaging or projects in github. I think is totally broken for that use case. One problem readability.</p> <p>In the <a href="https://gist.github.com/guillermo/0eb7e53fa687acbf05ea" rel="nofollow">initial example</a> the code is really small. Is something that I was always tire of writing again and again, but too small to even create a proper package.</p> <p>Summary: This is just a technique and you should have the criteria to know when to use it and when not to.</p></pre>captncraig: <pre><p>if you own the domain you can put meta tags to point it at the actual repo. Go get will work with that.</p></pre>

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

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