check-layers

command
v1.10.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 20, 2026 License: AGPL-3.0 Imports: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Command check-layers verifies the layered architecture. It enforces:

  • P1 — strict downward imports: every Go import must target a layer ≤ source layer - 1.
  • P2 — single upward interface per layer: when a destination layer declares `public:` in layers.yaml, cross-layer imports may only target one of those packages; sibling packages listed in `packages:` but absent from `public:` are layer-internal.
  • P5 — tests stay within their layer (when --tests is passed).

Reads layers.yaml from the repo root, runs `go list -json ./...`, walks the import graph, and exits non-zero on any forbidden edge.

Known transitional violations (listed under known_transitional in layers.yaml) are reported as warnings, not failures, so the build stays green during the simplification work even though violations exist.

Usage:

go run ./tools/check-layers ./...        — non-test imports only
go run ./tools/check-layers --tests ./... — also walk TestImports + XTestImports (P5)

See docs/architecture/05-VERIFICATION.md for the verification framework this is part of.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL