<hr/>**评论:**<br/><br/>arp242: <pre><p>I run these in my editor, as they'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'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'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'm not so sure about false positives from errorcheck. If you mean errors from close functions, I'd rather handle those than not.</p></pre>dlsniper: <pre><p>Yes, but I'm sure nobody handles errors from fmt.Printf, for example.</p>
<p>Also your comment about disabling linters doesn't make sense since the previous comment says you enable them all...</p></pre>Bake_Jailey: <pre><p>I've never had gometalinter show me a warning for fmt, even with everything enabled.</p>
<p>And I guess "I'm a madman" wasn't a strong enough hint that my answer wasn't completely serious.</p></pre>arp242: <pre><blockquote>
<p>produce too many false positives to be useful, like errorcheck. </p>
</blockquote>
<p>errcheck doesn't give me that many problems? The most common cases are either <code>Close()</code> where you're doing a read-only operation, or some <code>Write()</code> calls. It'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's a bit ugly, but in the past we'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
- 请尽量让自己的回复能够对别人有帮助
- 支持 Markdown 格式, **粗体**、~~删除线~~、
`单行代码`
- 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
- 图片支持拖拽、截图粘贴等方式上传