Skip to content

Modernize golangci-lint config#657

Merged
tamalsaha merged 1 commit into
masterfrom
ci/golangci-lint-gofumpt
Jul 10, 2026
Merged

Modernize golangci-lint config#657
tamalsaha merged 1 commit into
masterfrom
ci/golangci-lint-gofumpt

Conversation

@tamalsaha

@tamalsaha tamalsaha commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Summary

Modernize the .golangci.yml configuration for golangci-lint v2 and switch the configured formatter to gofumpt.

This also aligns the linter with the build image (ghcr.io/appscode/golang-dev:1.25), where gofmt is already a symlink shim to gofumpt v0.7.0 — so make fmt (via hack/fmt.sh's gofmt -s -w) and the linter now enforce the same formatting. No change to hack/fmt.sh is needed.

.golangci.yml

  • Enable bodyclose and prealloc linters (unparam was already enabled).
  • Move exclude-files / exclude-dirs out of the deprecated issues: block into linters.exclusions.paths — the correct location in golangci-lint v2.
  • Fix the over-escaped exclusion regex generated.*\\.gogenerated.*\.go (the double backslash matched a literal backslash rather than a dot).
  • Switch the formatter from gofmtgofumpt and drop the now-unneeded interface{}any rewrite rule (gofumpt performs this itself at go1.18+, and go.mod pins go1.25).

golangci-lint config verify passes and golangci-lint run reports 0 issues.

Resulting formatting

  • gofumpt reformat of five apis/**/register.go files (AddKnownTypes argument wrapping).
  • pkg/tableconvertor/util.go: use fmt.Fprintf(&sources, ...) instead of sources.WriteString(fmt.Sprintf(...)).

Test plan

  • golangci-lint config verify — valid
  • golangci-lint run — 0 issues
  • go build ./pkg/tableconvertor/...

kodiakhq[bot]
kodiakhq Bot previously approved these changes Jul 10, 2026
- Enable bodyclose and prealloc linters
- Move exclude-files/exclude-dirs to linters.exclusions.paths (golangci-lint
  v2 location) and fix over-escaped regex generated.*\\.go -> generated.*\.go
- Switch formatter from gofmt to gofumpt and drop the interface{} -> any
  rewrite rule (gofumpt is a stricter superset)
- Apply resulting gofumpt formatting and use fmt.Fprintf over
  Sprintf+WriteString in tableconvertor

Signed-off-by: Tamal Saha <tamal@appscode.com>
@tamalsaha tamalsaha changed the title Modernize golangci-lint config and switch to gofumpt Modernize golangci-lint config and switch formatter to gofumpt Jul 10, 2026
@tamalsaha tamalsaha changed the title Modernize golangci-lint config and switch formatter to gofumpt Modernize golangci-lint config Jul 10, 2026
@tamalsaha
tamalsaha merged commit cae64e5 into master Jul 10, 2026
7 checks passed
@tamalsaha
tamalsaha deleted the ci/golangci-lint-gofumpt branch July 10, 2026 13:40
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.

1 participant