# beltranaceves/uber-go-lint-style architecture

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

- Interactive diagram: https://gitdiagram.com/beltranaceves/uber-go-lint-style
- Repository: https://github.com/beltranaceves/uber-go-lint-style

## Overview

1. **What this repository is**
   - This is a **Go static-analysis plugin** for **golangci-lint** that enforces Uber Go style conventions.
   - The core runtime boundary is: **golangci-lint loads this module as a custom linter plugin**, and the plugin contributes one or more `go/analysis` analyzers.

2. **Primary execution path**
   - The main entrypoint is `plugin.go`.
   - It acts as the bridge between golangci-lint and the rule implementations in `rules/`, assembling the analyzers that get registered with the host linter.

3. **Rule engine subsystem**
   - The `rules/` directory is the main product surface: **one file per rule**, such as `atomic`, `error_wrap`, `import_group`, `no_panic`, `todo`, etc.
   - Each rule is an independent analyzer focused on a single style concern, which keeps the architecture modular and makes rule enable/disable behavior straightforward.

4. **Analysis model**
   - The repository is built around the standard Go analysis ecosystem (`go/analysis`, as described in the README).
   - Rules inspect Go source code and report diagnostics; the design is intentionally heuristic in some areas, because many style rules are subjective rather than purely semantic.

5. **Configuration and plugin packaging**
   - The repo supports **golangci-lint custom plugin configuration** via `.custom-gcl.yml` and `.golangci.yml`.
   - A notable architectural feature is runtime rule suppression through `disabled_rules_yaml`, which lets the host project selectively disable analyzers without changing code.
   - The setup flow is handled by `cmd/setup`, which generates the config files and a convenience `Makefile`.

6. **Rule documentation layer**
   - `RULES.md` is the user-facing catalog of enforced checks.
   - `style_guide/rules/*.md` appears to be the source/materialized documentation for each rule, tying implementation to the underlying Uber style guidance.
   - This docs layer is important because the project is as much a policy bundle as it is a code analyzer.

7. **Testing architecture**
   - `plugin_test.go` and the per-rule tests validate that analyzers are wired correctly and emit expected findings.
   - `testdata/` is the standard Go analyzer test corpus: it contains many small synthetic packages under `testdata/src/...` that exercise rule-specific good/bad cases.
   - The tests rely on import-path-shaped fixtures and `// want`-style expectations, which is typical for `go/analysis`-based linters.

8. **Test fixture organization**
   - The `testdata/src/testlintdata/...` subtree mirrors each rule name, so each analyzer has isolated fixtures.
   - There are also special fixture packages under `testdata/src/example.com`, `github.com`, `go.uber.org`, etc., to model external-import and package-structure scenarios that matter to style rules.

9. **Disabled-rule and integration coverage**
   - `test/plugin_disabled_rules_test.go` covers the config-driven rule suppression path, which is an important behavioral boundary: the same analyzer set can be pruned at runtime based on config.
   - This ensures the plugin behaves correctly both as a full policy bundle and as a selectively configured linter.

10. **Integration client**
   - `test-client/` is a separate Go module used for end-to-end validation of the built plugin in a realistic consumer setup.
   - It exercises the custom golangci-lint binary and serves as a smoke-test of packaging, configuration, and CLI wiring beyond unit tests.

11. **Automation and delivery**
   - `.github/workflows/go-test.yml` runs the repository’s test suite in CI.
   - `Makefile` provides local convenience targets, and the README emphasizes building a custom `golangci-lint` binary plus the plugin module.
   - The repo is therefore optimized for distribution as a **developer-tooling dependency**, not as an application service.

12. **Architectural summary**
   - The system splits cleanly into:
     - a **plugin wrapper** (`plugin.go`),
     - a **library of analyzers** (`rules/`),
     - a **fixture-driven validation layer** (`testdata/`, `plugin_test.go`),
     - and a **consumer/setup experience** (`cmd/setup`, `test-client`, config files, docs).
   - For a diagram, the key flow is: **Go source code → rule analyzers → diagnostics reported through golangci-lint**, with docs/config/test assets surrounding that core pipeline.

Main entry points: [`rules`](https://github.com/beltranaceves/uber-go-lint-style/tree/main/rules) (Style rules), [`cmd/setup/main.go`](https://github.com/beltranaceves/uber-go-lint-style/blob/main/cmd/setup/main.go) (Setup cmd), [`test-client/main.go`](https://github.com/beltranaceves/uber-go-lint-style/blob/main/test-client/main.go) (Test client), [`plugin_test.go`](https://github.com/beltranaceves/uber-go-lint-style/blob/main/plugin_test.go) (Plugin tests)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_core["Core plugin"]
  node_plugin["Plugin entry<br/>golangci-lint plugin<br/>[plugin.go]"]
end

subgraph group_rules["Rule analyzers"]
  node_rule_style_core["Style rules<br/>analyzer set"]
  node_rule_imports_and_packages["Imports & packages<br/>rule cluster<br/>[import_group.go]"]
  node_rule_functions_and_errors["Funcs & errors<br/>rule cluster<br/>[error_wrap.go]"]
  node_rule_data_and_types["Data & types<br/>rule cluster<br/>[struct_zero.go]"]
  node_rule_control_flow["Control flow<br/>rule cluster<br/>[no_panic.go]"]
  node_rule_formatting["Formatting<br/>rule cluster<br/>[line_length.go]"]
  node_rule_misc["Misc rules<br/>rule cluster<br/>[todo.go]"]
end

subgraph group_tests["Validation"]
  node_unit_tests["Plugin tests<br/>test suite<br/>[plugin_test.go]"]
  node_disabled_rules_test["Config tests<br/>integration test"]
  node_fixture_corpus[("Testdata corpus<br/>go/analysis fixtures")]
  node_external_fixtures["Import fixtures<br/>fixture packages<br/>[client.go]"]
end

subgraph group_docs["Policy docs"]
  node_rules_md["RULES.md<br/>rule catalog<br/>[RULES.md]"]
  node_style_guide["Style guide<br/>guidance docs<br/>[style.md]"]
  node_rule_docs["Rule docs<br/>markdown set<br/>[atomic.md]"]
end

subgraph group_tooling["Packaging"]
  node_setup_cmd["Setup cmd<br/>config generator<br/>[main.go]"]
  node_plugin_config["Plugin config<br/>gcl config<br/>[.custom-gcl.yml]"]
  node_golangci_config["Linter config<br/>gcl config<br/>[.golangci.yml]"]
  node_consumer_module["Test client<br/>consumer module<br/>[main.go]"]
  node_ci_workflow["CI workflow<br/>github actions<br/>[go-test.yml]"]
end

node_plugin -->|"registers"| node_rule_style_core
node_rule_style_core -->|"includes"| node_rule_imports_and_packages
node_rule_style_core -->|"includes"| node_rule_functions_and_errors
node_rule_style_core -->|"includes"| node_rule_data_and_types
node_rule_style_core -->|"includes"| node_rule_control_flow
node_rule_style_core -->|"includes"| node_rule_formatting
node_rule_style_core -->|"includes"| node_rule_misc
node_style_guide -->|"documents"| node_rule_docs
node_rules_md -->|"catalogs"| node_rule_style_core
node_setup_cmd -->|"generates"| node_plugin_config
node_setup_cmd -->|"generates"| node_golangci_config
node_setup_cmd -->|"bootstraps"| node_consumer_module
node_consumer_module -->|"loads"| node_plugin_config
node_consumer_module -->|"runs with"| node_golangci_config
node_unit_tests -->|"verifies"| node_plugin
node_unit_tests -->|"exercises"| node_fixture_corpus
node_disabled_rules_test -->|"verifies"| node_plugin_config
node_disabled_rules_test -->|"prunes"| node_plugin
node_fixture_corpus -->|"contains"| node_external_fixtures
node_ci_workflow -->|"runs"| node_unit_tests

click node_plugin "https://github.com/beltranaceves/uber-go-lint-style/blob/main/plugin.go"
click node_rule_style_core "https://github.com/beltranaceves/uber-go-lint-style/tree/main/rules"
click node_rule_imports_and_packages "https://github.com/beltranaceves/uber-go-lint-style/blob/main/rules/import_group.go"
click node_rule_functions_and_errors "https://github.com/beltranaceves/uber-go-lint-style/blob/main/rules/error_wrap.go"
click node_rule_data_and_types "https://github.com/beltranaceves/uber-go-lint-style/blob/main/rules/struct_zero.go"
click node_rule_control_flow "https://github.com/beltranaceves/uber-go-lint-style/blob/main/rules/no_panic.go"
click node_rule_formatting "https://github.com/beltranaceves/uber-go-lint-style/blob/main/rules/line_length.go"
click node_rule_misc "https://github.com/beltranaceves/uber-go-lint-style/blob/main/rules/todo.go"
click node_rules_md "https://github.com/beltranaceves/uber-go-lint-style/blob/main/RULES.md"
click node_style_guide "https://github.com/beltranaceves/uber-go-lint-style/blob/main/style_guide/style.md"
click node_rule_docs "https://github.com/beltranaceves/uber-go-lint-style/blob/main/style_guide/rules/atomic.md"
click node_setup_cmd "https://github.com/beltranaceves/uber-go-lint-style/blob/main/cmd/setup/main.go"
click node_plugin_config "https://github.com/beltranaceves/uber-go-lint-style/blob/main/test-client/.custom-gcl.yml"
click node_golangci_config "https://github.com/beltranaceves/uber-go-lint-style/blob/main/test-client/.golangci.yml"
click node_consumer_module "https://github.com/beltranaceves/uber-go-lint-style/blob/main/test-client/main.go"
click node_unit_tests "https://github.com/beltranaceves/uber-go-lint-style/blob/main/plugin_test.go"
click node_disabled_rules_test "https://github.com/beltranaceves/uber-go-lint-style/blob/main/test/plugin_disabled_rules_test.go"
click node_fixture_corpus "https://github.com/beltranaceves/uber-go-lint-style/tree/main/testdata/src/testlintdata"
click node_external_fixtures "https://github.com/beltranaceves/uber-go-lint-style/blob/main/testdata/src/example.com/client-go/client.go"
click node_ci_workflow "https://github.com/beltranaceves/uber-go-lint-style/blob/main/.github/workflows/go-test.yml"

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_plugin toneBlue
class node_rule_style_core,node_rule_imports_and_packages,node_rule_functions_and_errors,node_rule_data_and_types,node_rule_control_flow,node_rule_formatting,node_rule_misc toneAmber
class node_unit_tests,node_disabled_rules_test,node_fixture_corpus,node_external_fixtures toneMint
class node_rules_md,node_style_guide,node_rule_docs toneRose
class node_setup_cmd,node_plugin_config,node_golangci_config,node_consumer_module,node_ci_workflow toneIndigo
```

## Components

### Core plugin

Runtime bridge from golangci-lint into this repository's analyzers

- [Plugin entry](https://github.com/beltranaceves/uber-go-lint-style/blob/main/plugin.go): golangci-lint plugin · Assembles and exposes analyzers to the host linter · `plugin.go`

### Rule analyzers

Go/analysis checks grouped by style concern

- [Style rules](https://github.com/beltranaceves/uber-go-lint-style/tree/main/rules): analyzer set · Primary rule implementations covering names, declarations, flow, and formatting · `rules`
- [Imports & packages](https://github.com/beltranaceves/uber-go-lint-style/blob/main/rules/import_group.go): rule cluster · Rules for import grouping, aliases, package naming, and init/layout conventions · `rules/import_group.go`
- [Funcs & errors](https://github.com/beltranaceves/uber-go-lint-style/blob/main/rules/error_wrap.go): rule cluster · Rules for function naming, order, naked returns, and error construction/wrapping · `rules/error_wrap.go`
- [Data & types](https://github.com/beltranaceves/uber-go-lint-style/blob/main/rules/struct_zero.go): rule cluster · Rules for structs, interfaces, containers, maps, slices, pointers, and zero values · `rules/struct_zero.go`
- [Control flow](https://github.com/beltranaceves/uber-go-lint-style/blob/main/rules/no_panic.go): rule cluster · Rules for panic, goroutines, exits, nesting, and time usage · `rules/no_panic.go`
- [Formatting](https://github.com/beltranaceves/uber-go-lint-style/blob/main/rules/line_length.go): rule cluster · Rules for line length, printf usage, string conversion, and escapes · `rules/line_length.go`
- [Misc rules](https://github.com/beltranaceves/uber-go-lint-style/blob/main/rules/todo.go): rule cluster · Residual style checks such as TODOs, variable scope, and declarations · `rules/todo.go`

### Validation

Unit, integration, and fixture-based analyzer tests

- [Plugin tests](https://github.com/beltranaceves/uber-go-lint-style/blob/main/plugin_test.go): test suite · Direct tests for plugin wiring and rule registration · `plugin_test.go`
- [Config tests](https://github.com/beltranaceves/uber-go-lint-style/blob/main/test/plugin_disabled_rules_test.go): integration test · Verifies runtime suppression of analyzers via disabled rule config · `test/plugin_disabled_rules_test.go`
- [Testdata corpus](https://github.com/beltranaceves/uber-go-lint-style/tree/main/testdata/src/testlintdata): go/analysis fixtures · Synthetic packages and want-expectation inputs for analyzer behavior · `testdata/src/testlintdata`
- [Import fixtures](https://github.com/beltranaceves/uber-go-lint-style/blob/main/testdata/src/example.com/client-go/client.go): fixture packages · Special package trees that model external import paths and package shapes · `testdata/src/example.com/client-go/client.go`

### Policy docs

User-facing style guidance and rule catalog

- [RULES.md](https://github.com/beltranaceves/uber-go-lint-style/blob/main/RULES.md): rule catalog · User-facing index of enabled checks · `RULES.md`
- [Style guide](https://github.com/beltranaceves/uber-go-lint-style/blob/main/style_guide/style.md): guidance docs · Canonical policy documents backing the analyzer set · `style_guide/style.md`
- [Rule docs](https://github.com/beltranaceves/uber-go-lint-style/blob/main/style_guide/rules/atomic.md): markdown set · Per-rule documentation mirroring the implemented checks · `style_guide/rules/atomic.md`

### Packaging

Setup, config, and consumer integration assets

- [Setup cmd](https://github.com/beltranaceves/uber-go-lint-style/blob/main/cmd/setup/main.go): config generator · Generates custom golangci-lint config and Makefile scaffolding · `cmd/setup/main.go`
- [Plugin config](https://github.com/beltranaceves/uber-go-lint-style/blob/main/test-client/.custom-gcl.yml): gcl config · Custom golangci-lint plugin configuration and disabled rule wiring · `test-client/.custom-gcl.yml`
- [Linter config](https://github.com/beltranaceves/uber-go-lint-style/blob/main/test-client/.golangci.yml): gcl config · Consumer-side golangci-lint configuration for loading the plugin · `test-client/.golangci.yml`
- [Test client](https://github.com/beltranaceves/uber-go-lint-style/blob/main/test-client/main.go): consumer module · Separate Go module that exercises built plugin integration · `test-client/main.go`
- [CI workflow](https://github.com/beltranaceves/uber-go-lint-style/blob/main/.github/workflows/go-test.yml): github actions · Runs repository tests in continuous integration · `.github/workflows/go-test.yml`

## Connections

- Plugin entry → Style rules: registers · The plugin collects analyzers from the rule package and exposes them to golangci-lint
- Style rules → Imports & packages: includes · One major slice of the analyzer set focuses on import and package conventions
- Style rules → Funcs & errors: includes · Function and error-related checks are implemented as separate analyzers
- Style rules → Data & types: includes · Type, container, and zero-value style rules are grouped together
- Style rules → Control flow: includes · Flow-sensitive checks cover panic, goroutines, exits, and nesting
- Style rules → Formatting: includes · Formatting and text-convention rules live alongside semantic checks
- Style rules → Misc rules: includes · Miscellaneous heuristics round out the rule set
- Style guide → Rule docs: documents · Per-rule markdown captures the policy behind each analyzer
- RULES.md → Style rules: catalogs · The rule catalog summarizes the analyzers that the plugin can expose
- Setup cmd → Plugin config: generates · Setup tooling emits the custom plugin configuration
- Setup cmd → Linter config: generates · Setup tooling also emits the host linter config
- Setup cmd → Test client: bootstraps · The setup flow supports a ready-to-run consumer module and Makefile
- Test client → Plugin config: loads · The consumer module uses the custom plugin configuration to enable this linter
- Test client → Linter config: runs with · The integration client validates the host linter wiring
- Plugin tests → Plugin entry: verifies · Tests ensure analyzer registration and plugin wiring are correct
- Plugin tests → Testdata corpus: exercises · Analyzer behavior is checked against fixture packages and expected diagnostics
- Config tests → Plugin config: verifies · Tests cover runtime pruning of analyzers driven by config
- Config tests → Plugin entry: prunes · The active analyzer set is reduced before registration
- Testdata corpus → Import fixtures: contains · The corpus includes special packages for external import and package-shape scenarios
- CI workflow → Plugin tests: runs · CI executes the repository test suite
