<p>Hi, I'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 "examples" 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'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 "standard coding" when you are working with Go.</p>
<p>So in the end, this is just how you write Go. There's no need to create extra repositories or anything like that.</p></pre>
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889
0 回复
- 请尽量让自己的回复能够对别人有帮助
- 支持 Markdown 格式, **粗体**、~~删除线~~、
`单行代码`
- 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
- 图片支持拖拽、截图粘贴等方式上传