Debian Codegraph @

website/content/changes/2026.2.md

raw
1 ---
2 title: Staticcheck 2026.2 release notes
3 linkTitle: "2026.2 (v0.8.0)"
4 weight: -12
5 ---
6
7 ## Added support for Go 1.27
8
9 This release updates Staticcheck's database of deprecated standard library APIs
10 to cover Go 1.27. Furthermore, it adds support for two new language features:
11 [generic methods](https://tip.golang.org/issue/77273) and struct initializers
12 with [direct references to embedded
13 fields](https://github.com/golang/go/issues/9859)
14
15 ## Support for GOCACHEPROG
16
17 Staticcheck now supports the same `GOCACHEPROG` environment variable and
18 protocol as the `go` tool. This allows users to provide their own
19 implementation of the build/fact/diagnostic cache.
20
21 ## Case-insensitive check names
22
23 All places that accept names of checks, such as the `-checks` and `-explain`
24 flags, ignore directives, and the `checks` setting in configuration files now
25 ignore the case of the provided names. That is, `SA1000`, `sa1000`, and
26 `sA1000` all refer to the same check.
27
28 ## Performance improvements for some packages
29
30 We have made changes to better support code with very complex control flow
31 graphs, such as the output of wasm2go. In one particularly pathological case,
32 memory usage was reduced from 10 GiB to 1.5 GiB and wall time from 73 s to
33 13 s.
34
35 ## Checks
36
37 ### New checks
38
39 One new check has been added. {{< check "SA9010" >}} flags statements of the
40 form `defer foo()` where `foo` returns a function. Usually, functions like that
41 expect the user to defer calling the returned function.
42
43 For example:
44
45 ```go
46 // Start starts a thing. The returned function has to be called once the thing
47 // is no longer needed.
48 func Start() func() {
49 // do some work here
50 return func() {
51 // undo some work here
52 }
53 }
54
55 func user() {
56 // This is doubly wrong! It won't call Start until this function returns,
57 // and then it won't call the function returned by Start.
58 defer Start()
59 ...
60 }
61 ```
62
63 ### Changed checks
64
65 The following checks have been improved:
66
67 - {{< check "SA1019" >}} now flags uses of deprecated fields in struct
68 initializers. Additionally, it is more consistent in the way diagnostics are
69 formatted ({{< issue"" >}}).
70 - {{< check "SA1026" >}} and {{< check "SA9005" >}} now check calls to
71 `MarshalIdent` functions, too ({{< issue "" >}}).
72 - {{< check "SA4003" >}} now checks comparisons involving generics.
73 - {{< check "SA4006" >}} has gained support for compound operators (`+=`, `^=`,
74 etc) as well as postfix increment and decrement ({{< issue "" >}}).
75 - {{< check "SA4023" >}} has been reimplemented. As a result, it may find new
76 issues in existing code, but also miss issues it has found before.
77 - {{< check "SA5011" >}} has been disabled due to internal changes. It is
78 unclear whether it will be enabled again in the future. As an alternative,
79 gopls contains the
80 [nilness](https://go.dev/gopls/analyzers#nilness-check-for-redundant-or-impossible-nil-comparisons)
81 analyzer, which has similar checks.
82 - {{< check "SA6005" >}} emits a clearer diagnostic when the result of
83 `strings.EqualFold` has to be inverted ({{< issue "" >}}).
84 - Documentation has been added to several checks
85 ({{< check "SA1002" >}}, {{< check "SA1012" >}}, {{< check "SA1014" >}},
86 {{< check "SA1020" >}}, {{< check "SA2000" >}}, {{< check "SA2003" >}}, and
87 {{< check "SA4010" >}})
88 - {{< check "S1005" >}} no longer flags unnecessary assignments to the blank
89 identifier for map indexing. This is to allow `v, _ := m[k]` as a hint that the
90 key may be missing from the map but that using the zero value is fine.
91 - {{< check "U1000" >}} has gained better support for the combined use of
92 generics and interfaces. It should emit far fewer false positives now
93 ({{< issue "1616" >}}, {{< issue "1440" >}}, {{< issue "1294" >}}).
94 - {{< check "ST1001" >}} includes the new `simd/archsimd` package in the default
95 value of the `dot_import_whitelist` setting.
96
97 ## Staticcheck 2026.2.1 release notes {#2026.2.1}
98
99 This release fixes two false positives in {{< check "SA4023" >}} that were introduced with 2026.2:
100
101 - It no longer treats unconstrained generics as never nil ({{< issue "1736" >}}).
102 - It no longer triggers in situations that don't involve typed nils ({{< issue "1737" >}}).