Which linters do you use?

agolangf · · 334 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<hr/>**评论:**<br/><br/>arp242: <pre><p>I run these in my editor, as they&#39;re reasonably fast:</p> <pre><code>--enable=vet --enable=errcheck --enable=golint --enable=ineffassign --enable=goimports --enable=lll --line-length=120 </code></pre> <p>I run these on CI for most projects. They&#39;re not fast enough to run in the editor, but still useful enough to catch the occasional issue:</p> <pre><code>--enable=varcheck --enable=interfacer --enable=unconvert --enable=structcheck --enable=megacheck </code></pre></pre>Bake_Jailey: <pre><p><code>gometalinter --enable-all</code></p> <p>I&#39;m a madman.</p></pre>dlsniper: <pre><p>The problem is that some of those are useless, like gas, or produce too many false positives to be useful, like errorcheck. </p> <p>I use GoLand, which has its own linters, but before commits I run go vet, golint, and megacheck.</p></pre>Bake_Jailey: <pre><p>All of that is true. I did say it was mad.</p> <p>I usually disable gas, the sql checker, as well as the line length checker, plus extra filtering to deal with linters which descend into vendor without being asked.</p> <p>I&#39;m not so sure about false positives from errorcheck. If you mean errors from close functions, I&#39;d rather handle those than not.</p></pre>dlsniper: <pre><p>Yes, but I&#39;m sure nobody handles errors from fmt.Printf, for example.</p> <p>Also your comment about disabling linters doesn&#39;t make sense since the previous comment says you enable them all...</p></pre>Bake_Jailey: <pre><p>I&#39;ve never had gometalinter show me a warning for fmt, even with everything enabled.</p> <p>And I guess &#34;I&#39;m a madman&#34; wasn&#39;t a strong enough hint that my answer wasn&#39;t completely serious.</p></pre>arp242: <pre><blockquote> <p>produce too many false positives to be useful, like errorcheck. </p> </blockquote> <p>errcheck doesn&#39;t give me that many problems? The most common cases are either <code>Close()</code> where you&#39;re doing a read-only operation, or some <code>Write()</code> calls. It&#39;s not <em>that</em> common. You can also easily disable it with:</p> <pre><code>defer f.Close() // nolint: errcheck </code></pre> <p>Or for an entire function:</p> <pre><code>// nolint: errcheck func Foo() { } </code></pre> <p>It&#39;s a bit ugly, but in the past we&#39;ve had a lot of people ignoring error checks (especially in tests) which caused all sorts of issues.</p></pre>mikolaj: <pre><p>gometalinter with following linters: golint, gotype, deadcode</p></pre>cs-guy: <pre><p>go vet, golint, and <a href="https://github.com/dominikh/go-tools/tree/master/cmd/megacheck" rel="nofollow">megacheck</a></p></pre>

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

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