[Chore] Upgrade golangci-lint to v2.4.0 and adjust linting configurations #4007
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
Why are these changes needed?
This pull request upgrades golangci-lint from an outdated version (
v1.64.8) to a recent major version (v2.4.0). The primary motivations for this upgrade are:Key changes include:
Separation of Linters and Formatters:
gofmt,goimports, andgcihave been moved from thelinters.enablelist to the new top-levelformatters.enablesection, reflecting their primary role. Their settings are now underformatters.settings.Merge of the Linters:
staticcheck,stylecheck, andgosimpleare merged into one linter,staticcheck.Crucially, all custom configurations (
gocyclo,gci,goimports) and specific path exclusions have been preserved and migrated to the new v2.0 schema. This upgrade ensures we leverage the latest improvements and features of golangci-lint while maintaining our established code quality standards.For more details on the changes in v2.0, please refer to the official migration guide: https://golangci-lint.run/product/migration-guide/
Related issue number
Checks