Skip to content

What makes a linter a formatter #5671

Answered by ldez
mmorel-35 asked this question in Q&A
Apr 1, 2025 · 1 comments · 2 replies
Discussion options

You must be logged in to vote

Hello,

there are 2 main differences:

  • the notion of "style" vs "format"
  • their implementations

This is the same difference as govet and gofmt.

wsl, whitespace, etc. are analyzers (analysis.Analyzer), and are related to style (they don't format the code but detect style issues).

gofmt, goimports, etc. are formatters (func(src []byte) []byte), and are related to format (they don't detect style problems, they just apply a format).

We have a "bridge" to use formatters as a linter, but it's more of a convenience than their intended use.

FYI, technically, gci, gofmt, gofumpt, goimports have never been "linters"; they were just wrapped to fake a linter behavior.

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@alexandear
Comment options

@ldez
Comment options

ldez Apr 1, 2025
Maintainer

Answer selected by mmorel-35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants