Support `golangci-lint fmt --diff`
question
### Welcome
- [x] Yes, I understand that the GitHub action repository is not the repository of golangci-lint itself.
- [x] Yes, I've searched similar issues on GitHub and didn't find any.
### Your feature request related to a problem? Please describe.
Support `golangci-lint fmt --diff`
In https://github.com/golangci/golangci-lint-action/issues/1245, the claim is that `golangci-lint run` will run the same formatters that `golangci-lint fmt` would but I don't think that is true based on my experience.
Testing strategy:
1. (using the default/standard config)
1. First auto-fixing my codebase with `go run github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.6.0 run ./... --fix`
1. `go run github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.6.0 run ./...` now passes
1. But `go run github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.6.0 fmt ./...` changes even more things. (`--diff` also shows the changes)
### Describe the solution you'd like.
Add an option to check that there are no additional changes from auto-formatters (`golangci-lint fmt --diff`)
### Describe alternatives you've considered.
```yaml
jobs:
lint-go:
name: Lint Go
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Setup go
uses: actions/setup-go@be3c94b385c4f180051c996d336f57a34c397495 # v3.6.1
with:
go-version: "stable"
- name: Run golangci-lint (lint)
run: go run github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.6.1 run ./... --max-issues-per-linter=0
- name: Run golangci-lint (format)
run: go run github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.6.1 fmt ./... --diff
```
### Additional context.
_No response_
关闭于 2025-11-05 4 条评论