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

Support golangci-lint for formatting #409

Closed
autarch opened this issue Oct 4, 2022 · 1 comment
Closed

Support golangci-lint for formatting #409

autarch opened this issue Oct 4, 2022 · 1 comment

Comments

@autarch
Copy link

autarch commented Oct 4, 2022

We use golangci-lint for linting, including checking that code is formatted properly. It's formatting slightly differs from gofmt and goimports, so I'd prefer to use it to do formatting. I tried the following in my .emacs:

(setq gofmt-command "golangci-lint")
(setq gofmt-args '("run --disable-all -E goimports ./..."))

The problem is that go-mode is appending additional arguments like -w when it calls this command, and this isn't supported by golangci-lint.

@dominikh
Copy link
Owner

dominikh commented Oct 4, 2022

go-mode expects a proper gofmt-like command here, and I am not inclined to add a special case for a tool that isn't one and that, depending on the configuration, isn't capable of automatically applying fixes in the first place (golangci/golangci-lint#3230, golangci/golangci-lint#1577, golangci/golangci-lint#1510, golangci/golangci-lint#1726). It's also highly dubious that using just the goimports check in golangci-lint would disagree with actual goimports.

A formatter that is almost like gofmt but not quite would be gofumpt, but that is a proper drop-in replacement for gofmt and works with the existing gofmt-command setting.

@dominikh dominikh closed this as not planned Won't fix, can't repro, duplicate, stale Oct 4, 2022
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

No branches or pull requests

2 participants