Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Less verbose format checking #5733

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
maxclaus opened this issue Apr 14, 2025 · 5 comments
Closed
2 of 3 tasks

Less verbose format checking #5733

maxclaus opened this issue Apr 14, 2025 · 5 comments
Labels
area: formatters/fmt question Further information is requested

Comments

@maxclaus
Copy link

Welcome

How did you install golangci-lint?

Official binary

Your feature request related to a problem? Please describe

Running golangci-lint fmt --diff can be quite verbose when there are a lot of files not well formatted.

Describe the solution you'd like

It would be nice if there was a --check option like prettier --check. Where it prints only the file name, not the file content.

Describe alternatives you've considered

I tried piping the output to /dev/null as a workaround. But I was having trouble making it work in different OS environments. So, it would be nice if it was available built-in on the linter tool.

Additional context

A bit related to #5601.

Supporter

@maxclaus maxclaus added the enhancement New feature or improvement label Apr 14, 2025
Copy link

boring-cyborg bot commented Apr 14, 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 Apr 14, 2025

Hello,

Can I ask you what your usage of the golangci-lint fmt command is?

The golangci-lint fmt has been designed to format by default, because the formatting of the code is not optional.
The --diff is more related to CI.

Also, the formatters are run when using golangci-lint run, so the --diff option is less useful locally.

@ldez ldez added no decision No decision to fix or not feedback required Requires additional feedback proposal and removed enhancement New feature or improvement labels Apr 14, 2025
@maxclaus
Copy link
Author

maxclaus commented Apr 14, 2025

Not sure if I am doing something wrong but run command does not seem to check formatting issues for me.

For example, given this code:

// main project
package main

import (
	"fmt"
)

func main() {
fmt.Println("Test")
}

When I run the linter it reports no issues:

$ ./bin/golangci-lint run --default all --disable forbidigo
0 issues.

Once I run the formatter it does detect the formatting is wrong though:

$ ./bin/golangci-lint fmt --diff
diff /Users/maxnunes/Development/test-go-linter-fmt/main.go.orig /Users/maxnunes/Development/test-go-linter-fmt/main.go
--- /Users/maxnunes/Development/test-go-linter-fmt/main.go.orig
+++ /Users/maxnunes/Development/test-go-linter-fmt/main.go
@@ -6,5 +6,5 @@
 )

 func main() {
-fmt.Println("Test")
+       fmt.Println("Test")
 }

@ldez
Copy link
Member

ldez commented Apr 14, 2025

ok, it's because you are using the default formatter.

Use the following configuration to enable a formatter:

version: "2"

formatters:
  enable:
    - gofmt

@maxclaus
Copy link
Author

that works, thanks!

@ldez ldez added question Further information is requested and removed no decision No decision to fix or not feedback required Requires additional feedback proposal labels Apr 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: formatters/fmt question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants