check-layers

command
v1.10.0 Latest Latest
Warning

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

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

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