Why this matters
go.work provides a consistent build graph and avoids ad-hoc replaces that break tooling.
Maintain a single go.work at the monorepo root listing all local modules via use directives. Forbid go.mod replace directives that point to sibling modules (e.g., ../pkg) in workspace modules.
go.work provides a consistent build graph and avoids ad-hoc replaces that break tooling.
Side-by-side examples engineers can pattern-match during review.
module github.com/acme/service
require github.com/acme/lib v0.0.0
replace github.com/acme/lib => ../libgo 1.22
use (
./services/service
./libs/lib
)replace github.com/acme/lib => ../libgo.work
use ( ./services/service ./libs/lib )From the same buckets as this rule.