# mgechev/revive architecture

> Architecture diagram of the GitHub repository mgechev/revive, 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/mgechev/revive
- Repository: https://github.com/mgechev/revive

## Overview

Revive is a configurable Go source-code linter and extensible linting library. Its main workflow is: a user invokes the CLI with paths and options; configuration selects and configures rules and an output formatter; the runner discovers packages and delegates file analysis to the linter; rules report failures; and the selected formatter renders them for the user. The README also documents comment-based suppression, optional type checking, custom rules and formatters, and configurable exit codes. Some of those implementation details are unsampled, so documented links are shown without implying uninspected internals.

Main entry points: [`revivelib/core.go`](https://github.com/mgechev/revive/blob/master/revivelib/core.go) (Lint runner), [`rule`](https://github.com/mgechev/revive/tree/master/rule) (Rule implementations), [`cli/main.go`](https://github.com/mgechev/revive/blob/master/cli/main.go) (Command-line app), [`lint/file.go`](https://github.com/mgechev/revive/blob/master/lint/file.go) (File analysis)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["CLI and runner"]
  node_cli["Command-line app<br/>[main.go]"]
  node_runner["Lint runner<br/>[core.go]"]
  node_patterns["Include/exclude patterns<br/>[pattern.go]"]
end

subgraph group_config["Configuration"]
  node_config_loader["Config and registry<br/>[config.go]"]
  node_lint_config["Lint settings<br/>[config.go]"]
end

subgraph group_analysis["Lint analysis"]
  node_package_analysis["Package analysis<br/>[package.go]"]
  node_file_analysis["File analysis<br/>[file.go]"]
  node_file_filters["File suppression<br/>[filefilter.go]"]
  node_rule_api["Rule interface<br/>[rule.go]"]
  node_core_rules["Rule implementations"]
  node_exported_rule["Exported naming<br/>[exported.go]"]
  node_package_naming["Package naming<br/>[package_naming.go]"]
  node_struct_tags["Struct tag checks<br/>[struct_tag.go]"]
  node_time_date["Time/date checks<br/>[time_date.go]"]
end

subgraph group_output["Results and extensions"]
  node_failures["Lint failures<br/>[failure.go]"]
  node_formatter_registry["Formatter registry<br/>[config.go]"]
  node_formatters["Output formatters"]
  node_friendly_formatter["Friendly formatter<br/>[friendly.go]"]
  node_sarif_formatter["SARIF formatter<br/>[sarif.go]"]
  node_custom_rules["Custom rule support<br/>[extra_rule.go]"]
end

node_user(("Go developer"))
node_go_project["Go project"]
node_output_text["Rendered findings"]

node_user -->|"invokes"| node_cli
node_go_project -->|"selects paths"| node_cli
node_cli -->|"loads config"| node_config_loader
node_cli -->|"starts lint"| node_runner
node_cli -->|"builds patterns"| node_patterns
node_runner -->|"uses config"| node_config_loader
node_config_loader -->|"configures"| node_lint_config
node_config_loader -->|"registers rules"| node_core_rules
node_runner -->|"runs analysis"| node_package_analysis
node_package_analysis -->|"lints files"| node_file_analysis
node_file_analysis -.->|"applies rules"| node_rule_api
node_rule_api -.->|"implemented by"| node_core_rules
node_core_rules -.->|"includes"| node_exported_rule
node_core_rules -.->|"includes"| node_package_naming
node_core_rules -.->|"includes"| node_struct_tags
node_core_rules -.->|"includes"| node_time_date
node_file_analysis -.->|"reports"| node_failures
node_runner -->|"selects formatter"| node_formatter_registry
node_formatter_registry -->|"registers formats"| node_formatters
node_formatters -.->|"includes"| node_friendly_formatter
node_formatters -.->|"includes"| node_sarif_formatter
node_runner -->|"forwards failures"| node_failures
node_failures -.->|"formatted by"| node_formatters
node_runner -->|"returns output"| node_output_text
node_user -->|"extends linter"| node_custom_rules
node_file_analysis -.->|"honors suppression"| node_file_filters
node_package_analysis -->|"analyzes packages"| node_go_project
node_friendly_formatter -->|"renders findings"| node_output_text
node_sarif_formatter -->|"renders findings"| node_output_text

click node_cli "https://github.com/mgechev/revive/blob/master/cli/main.go"
click node_runner "https://github.com/mgechev/revive/blob/master/revivelib/core.go"
click node_patterns "https://github.com/mgechev/revive/blob/master/revivelib/pattern.go"
click node_config_loader "https://github.com/mgechev/revive/blob/master/config/config.go"
click node_lint_config "https://github.com/mgechev/revive/blob/master/lint/config.go"
click node_package_analysis "https://github.com/mgechev/revive/blob/master/lint/package.go"
click node_file_analysis "https://github.com/mgechev/revive/blob/master/lint/file.go"
click node_file_filters "https://github.com/mgechev/revive/blob/master/lint/filefilter.go"
click node_rule_api "https://github.com/mgechev/revive/blob/master/lint/rule.go"
click node_core_rules "https://github.com/mgechev/revive/tree/master/rule"
click node_exported_rule "https://github.com/mgechev/revive/blob/master/rule/exported.go"
click node_package_naming "https://github.com/mgechev/revive/blob/master/rule/package_naming.go"
click node_struct_tags "https://github.com/mgechev/revive/blob/master/rule/struct_tag.go"
click node_time_date "https://github.com/mgechev/revive/blob/master/rule/time_date.go"
click node_failures "https://github.com/mgechev/revive/blob/master/lint/failure.go"
click node_formatter_registry "https://github.com/mgechev/revive/blob/master/config/config.go"
click node_formatters "https://github.com/mgechev/revive/tree/master/formatter"
click node_friendly_formatter "https://github.com/mgechev/revive/blob/master/formatter/friendly.go"
click node_sarif_formatter "https://github.com/mgechev/revive/blob/master/formatter/sarif.go"
click node_custom_rules "https://github.com/mgechev/revive/blob/master/revivelib/extra_rule.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_runner,node_patterns toneBlue
class node_config_loader,node_lint_config toneAmber
class node_package_analysis,node_file_analysis,node_file_filters,node_rule_api,node_core_rules,node_exported_rule,node_package_naming,node_struct_tags,node_time_date toneMint
class node_failures,node_formatter_registry,node_formatters,node_friendly_formatter,node_sarif_formatter,node_custom_rules toneRose
class node_user,node_go_project,node_output_text toneIndigo
```

## Components

### CLI and runner

- [Command-line app](https://github.com/mgechev/revive/blob/master/cli/main.go): `cli/main.go`
- [Lint runner](https://github.com/mgechev/revive/blob/master/revivelib/core.go): `revivelib/core.go`
- [Include/exclude patterns](https://github.com/mgechev/revive/blob/master/revivelib/pattern.go): `revivelib/pattern.go`

### Configuration

- [Config and registry](https://github.com/mgechev/revive/blob/master/config/config.go): `config/config.go`
- [Lint settings](https://github.com/mgechev/revive/blob/master/lint/config.go): `lint/config.go`

### Lint analysis

- [Package analysis](https://github.com/mgechev/revive/blob/master/lint/package.go): `lint/package.go`
- [File analysis](https://github.com/mgechev/revive/blob/master/lint/file.go): `lint/file.go`
- [File suppression](https://github.com/mgechev/revive/blob/master/lint/filefilter.go): `lint/filefilter.go`
- [Rule interface](https://github.com/mgechev/revive/blob/master/lint/rule.go): `lint/rule.go`
- [Rule implementations](https://github.com/mgechev/revive/tree/master/rule): `rule`
- [Exported naming](https://github.com/mgechev/revive/blob/master/rule/exported.go): `rule/exported.go`
- [Package naming](https://github.com/mgechev/revive/blob/master/rule/package_naming.go): `rule/package_naming.go`
- [Struct tag checks](https://github.com/mgechev/revive/blob/master/rule/struct_tag.go): `rule/struct_tag.go`
- [Time/date checks](https://github.com/mgechev/revive/blob/master/rule/time_date.go): `rule/time_date.go`

### Results and extensions

- [Lint failures](https://github.com/mgechev/revive/blob/master/lint/failure.go): `lint/failure.go`
- [Formatter registry](https://github.com/mgechev/revive/blob/master/config/config.go): `config/config.go`
- [Output formatters](https://github.com/mgechev/revive/tree/master/formatter): `formatter`
- [Friendly formatter](https://github.com/mgechev/revive/blob/master/formatter/friendly.go): `formatter/friendly.go`
- [SARIF formatter](https://github.com/mgechev/revive/blob/master/formatter/sarif.go): `formatter/sarif.go`
- [Custom rule support](https://github.com/mgechev/revive/blob/master/revivelib/extra_rule.go): `revivelib/extra_rule.go`

### Other components

- **Go developer**
- **Go project**
- **Rendered findings**

## Connections

- Go developer → Command-line app: invokes (evidence: `README.md`)
- Go project → Command-line app: selects paths (evidence: `README.md`)
- Command-line app → Config and registry: loads config (evidence: `cli/main.go`)
- Command-line app → Lint runner: starts lint (evidence: `cli/main.go`)
- Command-line app → Include/exclude patterns: builds patterns (evidence: `cli/main.go`)
- Lint runner → Config and registry: uses config (evidence: `revivelib/core.go`)
- Config and registry → Lint settings: configures (evidence: `config/config.go`)
- Config and registry → Rule implementations: registers rules (evidence: `config/config.go`)
- Lint runner → Package analysis: runs analysis (evidence: `revivelib/core.go`)
- Package analysis → File analysis: lints files (evidence: `lint/package.go`)
- File analysis → Rule interface: applies rules
- Rule interface → Rule implementations: implemented by
- Rule implementations → Exported naming: includes
- Rule implementations → Package naming: includes
- Rule implementations → Struct tag checks: includes
- Rule implementations → Time/date checks: includes
- File analysis → Lint failures: reports
- Lint runner → Formatter registry: selects formatter (evidence: `revivelib/core.go`)
- Formatter registry → Output formatters: registers formats (evidence: `config/config.go`)
- Output formatters → Friendly formatter: includes
- Output formatters → SARIF formatter: includes
- Lint runner → Lint failures: forwards failures (evidence: `revivelib/core.go`)
- Lint failures → Output formatters: formatted by
- Lint runner → Rendered findings: returns output (evidence: `revivelib/core.go`)
- Go developer → Custom rule support: extends linter (evidence: `README.md`)
- File analysis → File suppression: honors suppression (evidence: `README.md`)
- Package analysis → Go project: analyzes packages
- Friendly formatter → Rendered findings: renders findings (evidence: `formatter/friendly.go`)
- SARIF formatter → Rendered findings: renders findings (evidence: `formatter/sarif.go`)
