Skip to content

build: Update golangci-lint to v2.0.2 #3488

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

jholdstock
Copy link
Member

Various changes in this new major version, including a new config file format:

  • gofmt and goimports are now categorized as formatters (instead of linters) and are moved to their own section.
  • The functionality of gosimple has been bundled into staticcheck. Only the gosimple behaviour is enabled (prefix "S1") and all other staticcheck behaviour is disabled.
  • typecheck is now always on and cannot be independently enabled/disabled.

Also includes minor changes to Go source which are explained in commit comments.

- Don't capitalize error strings.
- Ensure comments match field/func names.
- Simplify a switch statement by naking it non-naked.
"gosec" isn't enabled in config so the inline comment to disable it is
unnecessary.
The functionality of the old "structcheck" linter is now included in
"unused".
Various changes in this new major version, including a new config file
format:

- "gofmt" and "goimports" are now categorized as formatters
  (instead of linters) and are moved to their own section.
- The functionality of "gosimple" has been bundled into "staticcheck".
  Only the "gosimple" behaviour is enabled (prefix "S1") and all other
  "staticcheck" behaviour is disabled.
- "typecheck" is now always on and cannot be independently
  enabled/disabled.

Some changes needed to be made in source:

- blake256: Ignore govet false positive. It triggers on some func
  signatures which are similar to stdlib funcs but not identical.
Copy link
Member

@davecgh davecgh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes look good. I'm think I'm going to hold off on merging this though because the most recent version of gopls breaks with the v2 linter installed unless you also jump through some extra hoops to rename the binary, modify the linter flags in the editor's settings, and add an additional run param to the .golangci.yml.

I looked at the gopls issues and there is ongoing work to fix those things (and most of them have been merged to master already), so the next released version of gopls will likely work properly with it.

@davecgh davecgh added this to the 2.1.0 milestone Apr 12, 2025
@@ -9,7 +9,7 @@ import (
"fmt"
"net"
"net/http"
_ "net/http/pprof" // nolint:gosec
_ "net/http/pprof"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also should note that I do run gosec locally, but it is not enabled in the repo on purpose since it gives a lot of false positives.

I just tested and this no longer seems to trigger a lint warning in the most recent version, so I don't mind this being removed. I might end up bringing some back though if any new cases are introduced even though it isn't enabled for the repo.

@davecgh
Copy link
Member

davecgh commented Jun 3, 2025

As an update to this, I've been following the development and the current preview version of the go plugin works properly (with a few modifications to the config file to tell it to use v2), however it hasn't been released yet.

I'll merge this once the new version releases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants