github dominikh/go-tools 2026.2rc1
Staticcheck 2026.2rc1 (v0.8.0-rc.1)

pre-release5 hours ago

This is a release candidate of Staticcheck 2026.2. It has been built with Go 1.27rc1 and supports analyzing Go 1.27 code.

Added support for Go 1.27

This release updates Staticcheck’s database of deprecated standard library APIs to cover Go 1.27. Furthermore, it adds support for two new language features: generic methods and struct initializers with direct references to embedded fields

Support for GOCACHEPROG

Staticcheck now supports the same GOCACHEPROG environment variable and protocol as the go tool. This allows users to provide their own implementation of the build/fact/diagnostic cache.

Case-insensitive check names

All places that accept names of checks, such as the -checks and -explain flags, ignore directives, and the checks setting in configuration files now ignore the case of the provided names. That is, SA1000, sa1000, and sA1000 all refer to the same check.

Performance improvements for some packages

We have made changes to better support code with very complex control flow graphs, such as the output of wasm2go. In one particularly pathological case, memory usage was reduced from 10 GiB to 1.5 GiB and wall time from 73 s to 13 s.

Checks

New checks

One new check has been added. SA9010 flags statements of the form defer foo() where foo returns a function. Usually, functions like that expect the user to defer calling the returned function.

For example:

// Start starts a thing. The returned function has to be called once the thing
// is no longer needed.
func Start() func() {
	// do some work here
	return func() {
		// undo some work here
	}
}

func user() {
	// This is doubly wrong! It won't call Start until this function returns,
	// and then it won't call the function returned by Start.
	defer Start()
	...
}

Changed checks

The following checks have been improved:

  • SA1019 now flags uses of deprecated fields in struct initializers. Additionally, it is more consistent in the way diagnostics are formatted.
  • SA1026 and SA9005 now check calls to MarshalIdent functions, too.
  • SA4003 now checks comparisons involving generics.
  • SA4006 has gained support for compound operators (+=, ^=, etc) as well as postfix increment and decrement.
  • SA4023 has been reimplemented. As a result, it may find new issues in existing code, but also miss issues it has found before.
  • SA5011 has been disabled due to internal changes. It is unclear whether it will be enabled again in the future. As an alternative, gopls contains the nilness analyzer, which has similar checks.
  • SA6005 emits a clearer diagnostic when the result of strings.EqualFold has to be inverted.
  • Documentation has been added to several checks (SA1002, SA1012, SA1014, SA1020, SA2000, SA2003, and SA4010)
  • S1005 no longer flags unnecessary assignments to the blank identifier for map indexing. This is to allow v, _ := m[k] as a hint that the key may be missing from the map but that using the zero value is fine.
  • U1000 has gained better support for the combined use of generics and interfaces. It should emit far fewer false positives now (issue 1616, issue 1440, issue 1294).
  • ST1001 includes the new simd/archsimd package in the default value of the dot_import_whitelist setting.

Don't miss a new go-tools release

NewReleases is sending notifications on new releases.