What are some examples of really good golang code?

xuanbao · · 496 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>I&#39;m new to golang and trying to get a sense of how I should be writing my code. What are some examples of very high quality Go code?</p> <hr/>**评论:**<br/><br/>djherbis: <pre><p>Why not just read the std. lib? <a href="https://golang.org/pkg/" rel="nofollow">https://golang.org/pkg/</a></p> <p>There are links to the source on every method, type etc.</p> <p>It&#39;s not perfect, but it&#39;s generally held to a pretty high standard.</p></pre>peterbourgon: <pre><p>The nicest industrial code I&#39;ve read recently is <a href="https://github.com/hashicorp/memberlist" rel="nofollow">https://github.com/hashicorp/memberlist</a>.</p> <p>I&#39;m biased, but I think <a href="https://github.com/go-kit/kit" rel="nofollow">https://github.com/go-kit/kit</a> and <a href="https://github.com/oklog/oklog" rel="nofollow">https://github.com/oklog/oklog</a> are also held to very high standards.</p></pre>thesilentwitness: <pre><p><a href="https://github.com/hashicorp/memberlist/blob/master/memberlist.go#L198" rel="nofollow">https://github.com/hashicorp/memberlist/blob/master/memberlist.go#L198</a></p></pre>brianketelsen: <pre><p>I love the noms source code. Great interfaces, solid tests. Well worth the time to read that codebase. And it&#39;s bigger than a std lib package, so it shows real-world Go usage rather than the limited subset you see in stdlib.</p></pre>peterbourgon: <pre><p><a href="https://github.com/attic-labs/noms/tree/master/go" rel="nofollow">https://github.com/attic-labs/noms/tree/master/go</a> is <em>okay</em>... the package layout is rather suspect, e.g. packages types, util, etc. And package d is full of antipatterns. But the code itself is pretty clean.</p></pre>NeverUse-YouPromised: <pre><p>Not really as an example of good code, but an example of a good API and good documentation outside the standard library, <a href="https://godoc.org/github.com/andlabs/ui" rel="nofollow">andlabs/ui</a>.</p></pre>sairamk: <pre><p>Hugo is very well written - <a href="https://github.com/spf13/hugo" rel="nofollow">https://github.com/spf13/hugo</a></p></pre>tokenbucket: <pre><p>I agree that the std library is good, and studying it will also make you a better user of it. Couple of other suggestions:</p> <ul> <li><p>The Docker codebase: <a href="https://github.com/docker/docker" rel="nofollow">https://github.com/docker/docker</a> . </p></li> <li><p>Most anything by Dave Cheney: <a href="https://github.com/pkg/" rel="nofollow">https://github.com/pkg/</a> . FWIW, I really respect how polite and thoughtful he seems to be in his PR responses. </p></li> </ul></pre>peterbourgon: <pre><p>Definitely don&#39;t look at Docker, lol.</p></pre>yuhatemepvp: <pre><p>This guy knows what&#39;s up</p></pre>

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

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