Package examples in different repository?

blov · · 306 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>Hi, I&#39;m curious what you guys think is the better idea. </p> <p>Many people put examples (runnable programs exhibiting the functionality of their package) in the same repository as the actual package, under a &#34;examples&#34; folder. Other people put examples in a different repo (e.g. packageexamples).</p> <p>Which style do you prefer and why?</p> <hr/>**评论:**<br/><br/>peterbourgon: <pre><p>I can&#39;t think of many reasons to prefer a separate repo. Vendoring? Probably prefer an examples directory.</p></pre>shovelpost: <pre><p>In Go, <a href="https://blog.golang.org/examples" rel="nofollow">examples</a> are meant to live in the same package as normal code, alongside tests. They even share the same suffix as tests _test.go but the example functions begin with Example instead of Test.</p> <p>The way I see it, this promotes good engineering practices because it means that having docs, tests and runnable examples in your packages is just &#34;standard coding&#34; when you are working with Go.</p> <p>So in the end, this is just how you write Go. There&#39;s no need to create extra repositories or anything like that.</p></pre>

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

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