Documentation
¶
Overview ¶
Package guard enforces Portcullis's internal import DAG (design §3).
The architecture allows only a fixed set of import edges between internal packages: domain is a leaf, concrete packages depend only on domain, and a single composition root wires them together. This package encodes those allowed edges and checks them mechanically, so a forbidden import fails the build rather than only being documented. It is the analogue of a structural lint rule, expressed as a test that parses the source tree.
Index ¶
Constants ¶
const ModulePath = "github.com/JumpTechCode/portcullis"
ModulePath is the Go module path. Internal packages live under ModulePath + "/internal/".
Variables ¶
This section is empty.
Functions ¶
func ScanInternal ¶
ScanInternal parses every non-test .go file under moduleRoot/internal and returns, for each top-level internal package, the sorted unique set of internal packages it imports. Test files are excluded: the architecture invariant constrains production code, and external test packages legitimately import packages a production file may not.
Types ¶
type Violation ¶
type Violation struct {
// Pkg is the importing internal package's top-level name.
Pkg string
// Import is the imported internal package's top-level name, or a marker when
// Pkg itself is unclassified.
Import string
}
Violation is a forbidden internal import edge: package Pkg importing package Import, where that edge is not allowed by the DAG.
func Check ¶
Check returns the violations for a single internal package given the top-level names of the internal packages it imports. A package that is not a composition root and is absent from the allowed-edges map yields a single "unclassified" violation. Imports of a package by itself are ignored.