SA1012: false positive when calling method expression
Author: albertog-apCreated Jun 15, 2026Updated Jun 15, 2026
Labelsfalse-positive
I'm reporting a false positive for SA1012 (do not pass a nil Context, even if a function permits it; pass context.TODO if you are unsure about which Context to use) when invoking the implicit function of a method with a context.Context as the first parameter.
How to reproduce the issue: https://go.dev/play/p/I7dgCc4j0dU
package main
import "context"
type S struct{}
func (s *S) F(ctx context.Context) {}
func main() {
(*S).F(nil, context.Background())
}$ staticcheck main.go
main.go:10:9: do not pass a nil Context, even if a function permits it; pass context.TODO if you are unsure about which Context to use (SA1012)The first argument is incorrectly interpreted as the method's first parameter, whereas it is actually the method receiver
Additional informations
$ staticcheck -version
staticcheck 2026.1 (v0.7.0)$ staticcheck -debug.version
staticcheck 2026.1 (v0.7.0)
Compiled with Go version: go1.26.2
Main module:
honnef.co/go/[email protected] (sum: h1:w6WUp1VbkqPEgLz4rkBzH/CSU6HkoqNLp6GstyTx3lU=)
Dependencies:
github.com/BurntSushi/[email protected] (sum: h1:pxW6RcqyfI9/kWtOwnv/G+AzdKuy2ZrqINhenH4HyNs=)
golang.org/x/exp/[email protected] (sum: h1:1P7xPZEwZMoBoz0Yze5Nx2/4pxj6nw9ZqHWXqP0iRgQ=)
golang.org/x/[email protected] (sum: h1:HaW9xtz0+kOcWKwli0ZXy79Ix+UW/vOfmWI5QVd2tgI=)
golang.org/x/[email protected] (sum: h1:vV+1eWNmZ5geRlYjzm2adRgW2/mcpevXNg50YZtPCE4=)
golang.org/x/[email protected] (sum: h1:CHVDrNHx9ZoOrNN9kKWYIbT5Rj+WF2rlwPkhbQQ5V4U=)$ go version
go version go1.26.2 linux/amd64Source: dominikh/go-tools