Frequently Asked Questions

Staticcheck is wrong, what should I do?

First, make sure that Staticcheck is actually wrong. It can find very subtle bugs, and what may look like a false positive at first glance is usually a genuine bug. There is a long list of competent programmers who got it wrong before.

However, sometimes Staticcheck is wrong and you want to suppress a warning to get on with your work. In that case, you can use ignore directives to ignore specific problems. You should also report the false positive so that we can fix it. We don’t expect users to have to ignore many problems, and we always aim to avoid false positives.

Some checks, particularly those in the ST (stylecheck) category, may not be applicable to your code base at all. In that case, you should disable the check using the checks option in your configuration.

Staticcheck's suggestions don't apply to my version of Go