How many idioms did I break.

agolangf · · 486 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p><a href="https://github.com/project-empower/randomart-image" rel="nofollow">https://github.com/project-empower/randomart-image</a></p> <p>It&#39;s a first stab at anything Go. I&#39;m from C++. Would like a kind hearted soul to tell me how horrible it is...constructively :p</p> <p>Edit: Thanks for the input! I applied corrections based on input, including gomalinter</p> <hr/>**评论:**<br/><br/>jehaby: <pre><p>You might want to take a look at <a href="https://github.com/alecthomas/gometalinter" rel="nofollow">https://github.com/alecthomas/gometalinter</a></p></pre>Crazy__Eddie: <pre><p>This is great! Thanks!</p></pre>tclineks: <pre><p>Looks pretty good but there are some things to improve:</p> <ul> <li>snake case is not idiomatic for function names</li> <li>you aren&#39;t checking <a href="https://godoc.org/bufio#Scanner.Err" rel="nofollow">https://godoc.org/bufio#Scanner.Err</a></li> <li>the use of a channel for the scanner is IMO suspect</li> <li>you&#39;re not returning a non-zero exit code on line 70</li> <li>you&#39;re ignoring the possible error from png.Encode (errcheck linter should tell you this)</li> <li>it looks like the code hasn&#39;t been run through gofmt/goimports (some whitespace oddities)</li> <li>you have some commented out code in there</li> <li>the output filename should be a parameter (and probably default to stdout -- <a href="https://godoc.org/github.com/campoy/tools/imgcat" rel="nofollow">https://godoc.org/github.com/campoy/tools/imgcat</a> could be a fun addition!)</li> </ul> <p>that&#39;s a mix of idiom, error handling, tooling, and style nits -- I hope helpful and gently enough delivered! Welcome to go!</p></pre>Crazy__Eddie: <pre><blockquote> <p>the use of a channel for the scanner is IMO suspect</p> </blockquote> <p>Yeah, that was not necessary. I was playing with the idea of &#34;reactive&#34; and my little bit of knowledge there is &#34;functional reactive programming&#34;. Channels seemed like Go&#39;s react like crap. It&#39;s definitely overkill.</p> <p>Thanks for the feedback!</p></pre>0xjnml: <pre><p>Quite good for a first stab. Please use gofmt before committing.</p></pre>: <pre><p>[deleted]</p></pre>Crazy__Eddie: <pre><p>Ooh. Forgot about that thing. I saw it and meant to use it. Thanks!</p></pre>

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

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