The staticcheck
command works much like go build
or go vet
do.
It supports all of the same package patterns.
For example, staticcheck .
will check the current package, and staticcheck ./...
will check all packages.
For more details on specifying packages to check, see go help packages
You can use staticcheck -explain <check>
to get a helpful description of a check.
Every diagnostic that staticcheck
reports is annotated with the identifier of the specific check that found the issue.
For example, in
foo.go:1248:4: unnecessary use of fmt.Sprintf (S1039)
the check's identifier is S1039
.
Running staticcheck -explain S1039
will output the following:
Unnecessary use of fmt.Sprint
Calling fmt.Sprint with a single string argument is unnecessary and identical to using the string directly.
Available since
2020.1
Online documentation
https://staticcheck.io/docs/checks#S1039
The output includes a one-line summary,
one or more paragraphs of helpful text,
the first version of Staticcheck that the check appeared in,
and a link to online documentation, which contains the same information as the output of staticcheck -explain
.