operator-sdk generates invalid golangci-lint configuration #6922
Labels
language/go
Issue is related to a Go operator project
triage/support
Indicates an issue that is a support question.
Bug Report
What did you do?
After initializing a project and creating an API with
operator-sdk
, I attempted to rungolangcilint-run
.What did you expect to see?
I expected the linter to complete successfully.
What did you see instead? Under which circumstances?
The linter failed immediately with:
Adding the required
version: "2"
to the file leads to new errors:If we remove
typecheck
, we get:If we move
gofmt
andgoimports
to theformatters
section, we get:If we remove
exportloopref
andgosimple
from the configuration,golangci-lint
finally runs, but it then discovers a number of issues with the generated code:Environment
Operator type:
/language go
Kubernetes cluster type:
OpenShift
$ operator-sdk version
operator-sdk version: "v1.39.2", commit: "f01ea5405979ab9ce7049877f9a0c23927ccb2ec", kubernetes version: "1.31.0", go version: "go1.23.4", GOOS: "linux", GOARCH: "amd64"
$ go version
(if language is Go)go version go1.23.7 linux/amd64
$ kubectl version
Client Version: v1.31.2
Kustomize Version: v5.4.2
Possible Solution
Update the linting configuration and ensure that it does not report errors on the generated code.
Additional context
golangci-lint version:
golangci-lint has version 2.0.1 built with go1.24.1 from e8927ce2 on 2025-03-24T20:34:31Z
The text was updated successfully, but these errors were encountered: