# golangci/golangci-lint architecture

> Architecture diagram of the GitHub repository golangci/golangci-lint, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-07). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/golangci/golangci-lint
- Repository: https://github.com/golangci/golangci-lint

## Overview

golangci-lint is a Go static-analysis runner. Its principal workflow is: a user invokes the CLI, the run command loads configuration and selects linters, packages are analyzed, findings are processed, and configured output formats are printed. Separate capabilities include source formatting and configuration migration. The graph reflects README claims about parallel analysis, caching, YAML configuration, and the large linter catalog; connections for unsampled subsystems are omitted unless documented. The provided excerpts do not show every runtime call path.

Main entry points: [`pkg/commands/run.go`](https://github.com/golangci/golangci-lint/blob/main/pkg/commands/run.go) (Run orchestration), [`pkg/commands`](https://github.com/golangci/golangci-lint/tree/main/pkg/commands) (Commands), [`pkg/goanalysis/runner_loadingpackage.go`](https://github.com/golangci/golangci-lint/blob/main/pkg/goanalysis/runner_loadingpackage.go) (Package analysis), [`cmd/golangci-lint/main.go`](https://github.com/golangci/golangci-lint/blob/main/cmd/golangci-lint/main.go) (CLI entry)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["CLI and configuration"]
  node_cli["CLI entry<br/>[main.go]"]
  node_commands["Commands"]
  node_config["Configuration"]
end

subgraph group_analysis["Analysis engine"]
  node_run["Run orchestration<br/>[run.go]"]
  node_linters["Linter catalog<br/>[manager.go]"]
  node_adapters["Linter adapters"]
  node_context["Analysis context<br/>[context.go]"]
  node_loading["Package analysis"]
end

subgraph group_results["Findings and output"]
  node_issues["Issue model<br/>[issue.go]"]
  node_processors["Issue processing<br/>[processor.go]"]
  node_fixer["Automatic fixes<br/>[fixer.go]"]
  node_printer["Output printer<br/>[printer.go]"]
end

subgraph group_format["Formatting"]
  node_formatrunner["Format command<br/>[runner.go]"]
  node_formatters["Formatter registry<br/>[meta_formatter.go]"]
end

subgraph group_support["Caching and migration"]
  node_cache[("Analysis cache<br/>[cache.go]")]
  node_migrate["Config migration<br/>[migrate.go]"]
end

node_user(("CLI user"))

node_user -->|"invokes"| node_cli
node_cli -->|"executes"| node_commands
node_commands -.->|"runs analysis"| node_run
node_commands -.->|"formats files"| node_formatrunner
node_commands -.->|"migrates config"| node_migrate
node_run -->|"uses settings"| node_config
node_run -->|"selects linters"| node_linters
node_linters -.->|"builds linters"| node_adapters
node_run -->|"builds context"| node_context
node_context -.->|"loads packages"| node_loading
node_run -.->|"runs analyzers"| node_loading
node_run -->|"uses cache"| node_cache
node_loading -.->|"produces findings"| node_issues
node_run -->|"processes findings"| node_processors
node_processors -.->|"applies fixes"| node_fixer
node_run -->|"prints results"| node_printer
node_formatrunner -->|"formats source"| node_formatters
node_fixer -->|"formats edits"| node_formatters

click node_cli "https://github.com/golangci/golangci-lint/blob/main/cmd/golangci-lint/main.go"
click node_commands "https://github.com/golangci/golangci-lint/tree/main/pkg/commands"
click node_config "https://github.com/golangci/golangci-lint/tree/main/pkg/config"
click node_run "https://github.com/golangci/golangci-lint/blob/main/pkg/commands/run.go"
click node_linters "https://github.com/golangci/golangci-lint/blob/main/pkg/lint/lintersdb/manager.go"
click node_adapters "https://github.com/golangci/golangci-lint/tree/main/pkg/golinters"
click node_context "https://github.com/golangci/golangci-lint/blob/main/pkg/lint/context.go"
click node_loading "https://github.com/golangci/golangci-lint/blob/main/pkg/goanalysis/runner_loadingpackage.go"
click node_cache "https://github.com/golangci/golangci-lint/blob/main/internal/cache/cache.go"
click node_issues "https://github.com/golangci/golangci-lint/blob/main/pkg/result/issue.go"
click node_processors "https://github.com/golangci/golangci-lint/blob/main/pkg/result/processors/processor.go"
click node_fixer "https://github.com/golangci/golangci-lint/blob/main/pkg/result/processors/fixer.go"
click node_printer "https://github.com/golangci/golangci-lint/blob/main/pkg/printers/printer.go"
click node_formatrunner "https://github.com/golangci/golangci-lint/blob/main/pkg/goformat/runner.go"
click node_formatters "https://github.com/golangci/golangci-lint/blob/main/pkg/goformatters/meta_formatter.go"
click node_migrate "https://github.com/golangci/golangci-lint/blob/main/pkg/commands/internal/migrate/migrate.go"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_cli,node_commands,node_config,node_user toneBlue
class node_run,node_linters,node_adapters,node_context,node_loading toneAmber
class node_issues,node_processors,node_fixer,node_printer toneMint
class node_formatrunner,node_formatters toneRose
class node_cache,node_migrate toneIndigo
```

## Components

### CLI and configuration

- [CLI entry](https://github.com/golangci/golangci-lint/blob/main/cmd/golangci-lint/main.go): `cmd/golangci-lint/main.go`
- [Commands](https://github.com/golangci/golangci-lint/tree/main/pkg/commands): `pkg/commands`
- [Configuration](https://github.com/golangci/golangci-lint/tree/main/pkg/config): `pkg/config`

### Analysis engine

- [Run orchestration](https://github.com/golangci/golangci-lint/blob/main/pkg/commands/run.go): `pkg/commands/run.go`
- [Linter catalog](https://github.com/golangci/golangci-lint/blob/main/pkg/lint/lintersdb/manager.go): `pkg/lint/lintersdb/manager.go`
- [Linter adapters](https://github.com/golangci/golangci-lint/tree/main/pkg/golinters): `pkg/golinters`
- [Analysis context](https://github.com/golangci/golangci-lint/blob/main/pkg/lint/context.go): `pkg/lint/context.go`
- [Package analysis](https://github.com/golangci/golangci-lint/blob/main/pkg/goanalysis/runner_loadingpackage.go): `pkg/goanalysis/runner_loadingpackage.go`

### Findings and output

- [Issue model](https://github.com/golangci/golangci-lint/blob/main/pkg/result/issue.go): `pkg/result/issue.go`
- [Issue processing](https://github.com/golangci/golangci-lint/blob/main/pkg/result/processors/processor.go): `pkg/result/processors/processor.go`
- [Automatic fixes](https://github.com/golangci/golangci-lint/blob/main/pkg/result/processors/fixer.go): `pkg/result/processors/fixer.go`
- [Output printer](https://github.com/golangci/golangci-lint/blob/main/pkg/printers/printer.go): `pkg/printers/printer.go`

### Formatting

- [Format command](https://github.com/golangci/golangci-lint/blob/main/pkg/goformat/runner.go): `pkg/goformat/runner.go`
- [Formatter registry](https://github.com/golangci/golangci-lint/blob/main/pkg/goformatters/meta_formatter.go): `pkg/goformatters/meta_formatter.go`

### Caching and migration

- [Analysis cache](https://github.com/golangci/golangci-lint/blob/main/internal/cache/cache.go): `internal/cache/cache.go`
- [Config migration](https://github.com/golangci/golangci-lint/blob/main/pkg/commands/internal/migrate/migrate.go): `pkg/commands/internal/migrate/migrate.go`

### Other components

- **CLI user**

## Connections

- CLI user → CLI entry: invokes (evidence: `cmd/golangci-lint/main.go`)
- CLI entry → Commands: executes (evidence: `cmd/golangci-lint/main.go`)
- Commands → Run orchestration: runs analysis
- Commands → Format command: formats files
- Commands → Config migration: migrates config
- Run orchestration → Configuration: uses settings (evidence: `pkg/commands/run.go`)
- Run orchestration → Linter catalog: selects linters (evidence: `pkg/commands/run.go`)
- Linter catalog → Linter adapters: builds linters
- Run orchestration → Analysis context: builds context (evidence: `pkg/commands/run.go`)
- Analysis context → Package analysis: loads packages
- Run orchestration → Package analysis: runs analyzers
- Run orchestration → Analysis cache: uses cache (evidence: `pkg/commands/run.go`)
- Package analysis → Issue model: produces findings
- Run orchestration → Issue processing: processes findings (evidence: `pkg/commands/run.go`)
- Issue processing → Automatic fixes: applies fixes
- Run orchestration → Output printer: prints results (evidence: `pkg/commands/run.go`)
- Format command → Formatter registry: formats source (evidence: `pkg/goformat/runner.go`)
- Automatic fixes → Formatter registry: formats edits (evidence: `pkg/result/processors/fixer.go`)
