-
-
Notifications
You must be signed in to change notification settings - Fork 424
Expand file tree
/
Copy pathrun.html
More file actions
45 lines (33 loc) · 1.46 KB
/
Copy pathrun.html
File metadata and controls
45 lines (33 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<h2>Running Staticcheck</h2>
<h3>Checking packages</h3>
<p>
The <code>staticcheck</code> command works much like <code>go build</code> or <code>go vet</code> do.
It supports all of the same package patterns.
For example, <code>staticcheck .</code> will check the current package, and <code>staticcheck ./...</code> will check all packages.
For more details on specifying packages to check, see <code>go help packages</code>
</p>
<h3>Explaining checks</h3>
<p>
You can use <code>staticcheck -explain <check></code> to get a helpful description of a check.
</p>
<p>
Every diagnostic that <code>staticcheck</code> reports is annotated with the identifier of the specific check that found the issue.
For example, in
</p>
<pre><code>foo.go:1248:4: unnecessary use of fmt.Sprintf (S1039)</code></pre>
<p>
the check's identifier is <code>S1039</code>.
Running <code>staticcheck -explain S1039</code> will output the following:
</p>
<pre><code>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.dev/docs/checks#S1039</code></pre>
<p>
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 <code>staticcheck -explain</code>.
</p>