Skip to content

Add an option to golangci-lint fmt to check if the code is formatted #5601

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

Closed
2 of 3 tasks
sorairolake opened this issue Mar 24, 2025 · 3 comments
Closed
2 of 3 tasks
Labels
question Further information is requested

Comments

@sorairolake
Copy link

Welcome

How did you install golangci-lint?

go tool

Your feature request related to a problem? Please describe

In golangci-lint v1, we could check if the code is formatted with golangci-lint run -E gofmt, golangci-lint run -E goimports, etc. But I couldn't find a way to do this with golangci-lint v2.

Describe the solution you'd like

golangci-lint fmt --check

Describe alternatives you've considered

golangci-lint fmt
git diff --exit-code

Additional context

No response

Supporter

@sorairolake sorairolake added the enhancement New feature or improvement label Mar 24, 2025
Copy link

boring-cyborg bot commented Mar 24, 2025

Hey, thank you for opening your first Issue ! 🙂 If you would like to contribute we have a guide for contributors.

@ldez
Copy link
Member

ldez commented Mar 24, 2025

Hello,

The option already exists, it's golangci-lint fmt --diff.

https://golangci-lint.run/usage/configuration/#fmt

@ldez ldez added question Further information is requested and removed enhancement New feature or improvement labels Mar 24, 2025
@ldez ldez closed this as completed Mar 24, 2025
@sorairolake
Copy link
Author

@ldez I knew about that option, but I assumed it only show the difference and didn't know it can be used for this purpose. Thanks.

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

No branches or pull requests

2 participants