Exemplary Go projects in github?

agolangf · · 463 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>Does anyone have any really good example(s) of Go project(s) in github?</p> <p>I&#39;d like to see a small to medium sized code base, with sterling packages and file layout. Bonus points for a Makefile or some other build tool input.</p> <hr/>**评论:**<br/><br/>onyno: <pre><p><a href="https://github.com/kubernetes/kubernetes" rel="nofollow">https://github.com/kubernetes/kubernetes</a></p> <p>As for makefiles, it’s true that pure GO projects don’t require them, but when you start adding in JS or docker and integration testing - GO’s built in tooling lacks </p></pre>sh41: <pre><p>Do you consider kubernetes to be a small to medium sized code base?</p></pre>TheBeasSneeze: <pre><p>I would not call the kubernetes codebase good, the project is, the application itself is but the codebase quite clearly has loads of different coding styles, python style, java, c. It&#39;s a bit of a mishmash.</p></pre>sh41: <pre><p>Here&#39;s a small-sized example:</p> <p><a href="https://github.com/rsc/pdf">https://github.com/rsc/pdf</a></p> <p>Here&#39;s a medium-sized example:</p> <p><a href="https://github.com/robpike/ivy">https://github.com/robpike/ivy</a></p> <p>You didn&#39;t ask for it, but here&#39;s a large-sized example:</p> <p><a href="https://github.com/upspin/upspin">https://github.com/upspin/upspin</a></p> <blockquote> <p>Bonus points for a Makefile or some other build tool input.</p> </blockquote> <p>High-quality Go packages typically don&#39;t need a Makefile for simple tasks like building, testing, etc. Compared to the <code>go</code> tool, it&#39;s non-standard (doesn&#39;t run the same on all 3 OSes), unnecessary (for things that can be done with the <code>go</code> tool), and adds complexity and mental overhead.</p></pre>driusan: <pre><p>There&#39;s far more than 3 OSes that Go supports.</p></pre>sh41: <pre><p>I said it doesn&#39;t run <em>the same</em>, that means it has different behavior. There are many different flavors of <code>make</code> that all use the same Makefile name.</p></pre>dAnjou: <pre><p>You completely underestimate what a Makefile is and can be. Like with good code a well written Makefile does not only contain instructions for the computer but it can also be an entry point for humans who want to explore the project.</p> <p>Check out <a href="https://github.com/dAnjou/goup/blob/master/Makefile" rel="nofollow">the Makefile in my project</a>. I use it to create builds and packages that I can then release, in fact everyone who has Docker installed can use this Makefile - either by running it or simply by reading it - to build the tool the way it&#39;s supposed to be built without even installing Go on their system.</p> <p><strong>EDIT</strong> <a href="/u/bediger4000" rel="nofollow">/u/bediger4000</a>, the Go code in my project that I linked here is probably not very good - I wrote it to get my feet wet with Go - but maybe my Makefile and Dockerfile are interesting.</p></pre>sh41: <pre><p>Using Makefiles for things that the <code>go</code> tool doesn&#39;t support is completely okay and helpful.</p> <p>I&#39;ve just seen far too many Go packages that have Makefiles that wrap around the <code>go</code> tool to build, install, test. I&#39;d rather be able to do <code>go test import/path</code> than figure out what the author invented.</p></pre>dAnjou: <pre><blockquote> <p>Using Makefiles for things that the <code>go</code> tool doesn&#39;t support is completely okay and helpful.</p> </blockquote> <p>Then you should phrase things like this differently:</p> <blockquote> <p>High-quality Go packages don&#39;t need a Makefile, it&#39;s [...] unnecessary (you can do everything you need with the <code>go</code> tool)</p> </blockquote></pre>sh41: <pre><p>Thanks, edited my post. Hope the new phrasing is better.</p></pre>datskinnyguy_: <pre><p>You can check out <a href="https://github.com/avelino/awesome-go" rel="nofollow">awesome-go</a> for small to big projects in various kinds of domains.</p></pre>dulanov: <pre><p>Look at my project - <a href="https://github.com/nem-toolchain/nem-toolchain" rel="nofollow">https://github.com/nem-toolchain/nem-toolchain</a></p></pre>natefinch: <pre><p>If you&#39;re looking for a build tool, <a href="https://magefile.org" rel="nofollow">https://magefile.org</a> is a makefile-like tool that uses Go instead of bash.</p> <p>While it&#39;s true that simple projects don&#39;t need a makefile (usually this includes almost all libraries), it&#39;s fairly common for compiled binaries to need more than go install. Many people like to embed the commit hash and tagged version and build timestamp in the binary, and that involves a command line that is very tedious and error prone to type out each time, so a lot of people reach for a script to remember that for them.</p> <p>There&#39;s no one true layout, it often depends on the specifics of your project. The key is to use packages to your advantage to manage separation of concerns. Small packages are ok... big packages (i.e. those with a large API surface) can sometimes get unwieldy.</p></pre>whmartins: <pre><p>Don&#39;t know if it isn&#39;t a little bigger than you expect, but I like to see how hashicorp&#39;s go projects are structured. Specifically, Consul (<a href="https://github.com/hashicorp/consul" rel="nofollow">https://github.com/hashicorp/consul</a>)</p></pre>

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

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