Skip to content
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

[v1.14] golangci: Enable errorlint #31793

Merged
merged 3 commits into from
Apr 17, 2024
Merged

[v1.14] golangci: Enable errorlint #31793

merged 3 commits into from
Apr 17, 2024

Commits on Apr 16, 2024

  1. golangci: Update golanci-lint version to the same as GH action

    'make lint' fails like this:
    
    docker run --rm -v `pwd`:/app -w /app docker.io/golangci/golangci-lint:v1.53.3@sha256:1e0e2867b387bf68762427db499a963e43582b06819992db205fc31daa75ceea golangci-lint run
    level=error msg="Running error: context loading failed: failed to load packages: failed to load with go/packages: err: exit status 1: stderr: go: errors parsing go.mod:\n/app/go.mod:4: invalid go version '1.21.0': must match format 1.23\n"
    make: *** [Makefile:424: golangci-lint] Error 3
    
    This is due to a too old Go version within the golangci-lint v1.53.3 image:
    
    $ docker run --rm -v `pwd`:/app -w /app docker.io/golangci/golangci-lint:v1.53.3@sha256:1e0e2867b387bf68762427db499a963e43582b06819992db205fc31daa75ceea go version
    go version go1.20.5 linux/arm64
    
    Fix by using the same golangci-lint version for `make lint` as we already
    use for the GH Go lint action.
    
    Signed-off-by: Jarno Rajahalme <jarno@isovalent.com>
    jrajahalme committed Apr 16, 2024
    Configuration menu
    Copy the full SHA
    80b69ac View commit details
    Browse the repository at this point in the history
  2. golangci: Enable errorlint

    [ upstream commit d20f15e ]
    
    Enable errorlint in golangci-lint to catch uses of improper formatters
    for Go errors. This helps avoid unnecessary error/warning logs that
    cause CI flakes, when benign error cases are not caught due to failing
    error unwrapping when a string or value formatter has been used instead
    of the dedicated `%w`.
    
    Related: #31147
    Signed-off-by: Jarno Rajahalme <jarno@isovalent.com>
    jrajahalme committed Apr 16, 2024
    Configuration menu
    Copy the full SHA
    2654149 View commit details
    Browse the repository at this point in the history
  3. errors: Precede with colon

    [ upstream commit fe46958 ]
    
    Precede each `%w` formatter with a colon.
    
    Signed-off-by: Jarno Rajahalme <jarno@isovalent.com>
    jrajahalme committed Apr 16, 2024
    Configuration menu
    Copy the full SHA
    4a96640 View commit details
    Browse the repository at this point in the history