modboundary

package module
v0.0.0-...-5ba392b Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package modboundary provides a go/analysis Analyzer that flags direct imports between sibling feature modules, enforcing the pattern used throughout Modulex's examples: modules communicate through the shared registry (typed services and events), not by importing each other's implementation packages directly.

This is deliberately a separate, optional tool rather than an enforcement mechanism baked into the core modulex package: Modulex does not claim to enforce architectural boundaries at compile time (see docs/adr/adr-0030-modulex-release-readiness.md), and consumers who want static enforcement can opt into this analyzer without the core package depending on golang.org/x/tools.

Import-boundary checks

A "module" is the first import-path segment below the configured -root flag. A file belongs to the module its own package path resolves to. An import is flagged if:

  • its path also has the -root prefix,
  • its module differs from the current file's module, and
  • the imported package's last path segment is not in the -allow list (a comma-separated list of subpackage names that are safe to share across module boundaries, e.g. "ports"; default "ports").

Given root "example.com/app/modules", a file in "example.com/app/modules/orders" importing "example.com/app/modules/billing/ports" is allowed, but importing "example.com/app/modules/billing/service" is flagged.

Composition roots (package main) are exempt: wiring modules together by importing their constructors is their entire purpose, so files in a "package main" are never checked as importers. External test packages (files declaring "package foo_test") are treated as part of the module they test, so a module's own tests may import it freely.

Database-boundary checks

When -dbschema is set to a glob pattern for SQL migration files, the analyzer extracts CREATE TABLE and CREATE VIEW statements from those files and flags any Go file under -root that references a table owned by a different module. Table names listed in -sqltables (comma-separated) are exempt as shared system tables.

Index

Constants

This section is empty.

Variables

View Source
var Analyzer = &analysis.Analyzer{
	Name: "modboundary",
	Doc:  "reports imports and database table references that cross feature-module boundaries",
	Run:  run,
}

Analyzer reports direct imports between sibling feature modules under -root that do not go through an allow-listed subpackage, and optionally flags cross-module database table references when -dbschema is provided.

Functions

This section is empty.

Types

This section is empty.

Directories

Path Synopsis
cmd
modboundary command

Jump to

Keyboard shortcuts

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