Debian Codegraph @

doc/run.html

raw
1 <h2>Running Staticcheck</h2>
2
3 <h3>Checking packages</h3>
4
5 <p>
6 The <code>staticcheck</code> command works much like <code>go build</code> or <code>go vet</code> do.
7 It supports all of the same package patterns.
8 For example, <code>staticcheck .</code> will check the current package, and <code>staticcheck ./...</code> will check all packages.
9 For more details on specifying packages to check, see <code>go help packages</code>
10 </p>
11
12 <h3>Explaining checks</h3>
13
14 <p>
15 You can use <code>staticcheck -explain &lt;check&gt;</code> to get a helpful description of a check.
16 </p>
17
18 <p>
19 Every diagnostic that <code>staticcheck</code> reports is annotated with the identifier of the specific check that found the issue.
20 For example, in
21 </p>
22
23 <pre><code>foo.go:1248:4: unnecessary use of fmt.Sprintf (S1039)</code></pre>
24
25 <p>
26 the check's identifier is <code>S1039</code>.
27 Running <code>staticcheck -explain S1039</code> will output the following:
28 </p>
29
30 <pre><code>Unnecessary use of fmt.Sprint
31
32 Calling fmt.Sprint with a single string argument is unnecessary and identical to using the string directly.
33
34 Available since
35 2020.1
36
37 Online documentation
38 https://staticcheck.dev/docs/checks#S1039</code></pre>
39
40 <p>
41 The output includes a one-line summary,
42 one or more paragraphs of helpful text,
43 the first version of Staticcheck that the check appeared in,
44 and a link to online documentation, which contains the same information as the output of <code>staticcheck -explain</code>.
45 </p>