False negatives with exhaustruct
caused by upgrade to Go 1.23
#5416
Labels
exhaustruct
caused by upgrade to Go 1.23
#5416
Welcome
typecheck
section of the FAQ.Description of the problem
The
exhaustruct
linter has false positives ever sincegolangci-lint
upgraded to Go 1.23 in the v1.65.0 release. That release replaced thego 1.22
directive ingo.mod
withgo 1.23
, causing the linter's behaviour to change.I used
git bisect
to identify PR #5224 as the one that introduced the change. Further investigation confirmed that changing thego 1.22
directive togo 1.23
is what causes the change in behaviour.The issue is that in
golangci-lint
v1.63.x, theexhaustruct
linter reported missing fields in structs where the type was a type alias. In v1.64.x, the linter no longer reports missing fields in structs where the type is an alias. See below for an example of code that reports an error with v1.64 but not with v1.65.The
exhaustruct
linter was not upgraded in the v1.64 release ofgolangci-lint
.Running the linter directly does not suffer from the same issue, because that project's
go.mod
contains thego 1.21
directive. The issue only occurs when the analyzer is imported as a library into a project withgo 1.23
orgo 1.24
in itsgo.mod
.I want to be clear: I don't think the buggy code is in
golangci-lint
. But the bug only appears ingolangci-lint
. I've opened an issue on the linter's repository to fix this: GaijinEntertainment/go-exhaustruct#129. I am opening this issue here to track the problem, in case other analyzers are also affected.Version of golangci-lint
Version with incorrect linter behaviour:
Version with correct linter behaviour:
Configuration
$ golangci-lint run --enable-only=exhaustruct
Go environment
Verbose output of running
With
golangci-lint
v1.64.4:With
golangci-lint
v1.63.4:A minimal reproducible example or link to a public repository
Validation
Supporter
The text was updated successfully, but these errors were encountered: