<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>
![](https://static.golangjob.cn/static/img/banner.png)