Skip to content
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

feat(golangcilint): add formatting capabilities #662

Open
wants to merge 2 commits into
base: golangci-v2
Choose a base branch
from

Conversation

fredrikaverpil
Copy link
Member

@fredrikaverpil fredrikaverpil commented Mar 25, 2025

Why?

  • golangci-lint fmt is a new command in golangci-lint v2.

What?

  • Add the formatters section to the config.
  • Add new sggolangcilint.Fmt and sggolangcilint.FmtFix functions.
  • Call sggolangcilint.Fmt instead of sggolines.Format from main.go.
  • Run make go-format-fix to fix the files which are in need of formatting.

Notes

  • Builds upon feat(golangcilint): bump to v2 #661
  • The only difference between Fmt and FmtFix is that the --diff argument is passed into the former. I think, however, it is clearer to provide these two explicit functions. But if you disagree, we can just call the Fmt function with a --diff argument for checking and omitting it for writing.

@fredrikaverpil fredrikaverpil self-assigned this Mar 25, 2025
@fredrikaverpil fredrikaverpil changed the base branch from master to golangci-v2 March 25, 2025 09:02
@fredrikaverpil fredrikaverpil marked this pull request as ready for review March 25, 2025 10:26
@fredrikaverpil fredrikaverpil requested review from a team as code owners March 25, 2025 10:26
if err != nil {
return err
}
if d.IsDir() || d.Name() != "go.mod" {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if d.IsDir() || d.Name() != "go.mod" {
if d.IsDir() || d.Name() == "go.mod" {

or ideally check the file extension is .go?

@fredrikaverpil fredrikaverpil force-pushed the golangci-v2 branch 3 times, most recently from df59ac3 to eef925f Compare March 27, 2025 08:41
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.

2 participants