loader

package
v0.0.0-...-c349e42 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package loader is the front of the static pipeline: it type-checks one service unit with go/packages and hands the result to SSA construction. The unit is a single service directory (its "./..." packages); first-party siblings in a monorepo resolve through the active go.work / go.mod, while the bus and peer services remain the boundary.

It fails loudly. A load error, or any type-check error anywhere in the loaded graph, aborts — every downstream stage assumes a complete, well-typed program, so a partial load must never be silently analyzed.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Service

type Service struct {
	// Dir is the directory the unit was loaded from.
	Dir string
	// Module is the unit's module (nil only if the toolchain reported none).
	Module *packages.Module
	// Packages are the unit's first-party packages, sorted by import path for
	// determinism. Their dependencies are reachable through the import graph but
	// are not listed here.
	Packages []*packages.Package
}

Service is one loaded, type-checked service unit.

func Load

func Load(dir string) (*Service, error)

Load type-checks the packages rooted at dir (the "./..." pattern relative to dir) and returns them as one service unit.

func (*Service) ExtraInitialPackages

func (s *Service) ExtraInitialPackages(paths []string) []*packages.Package

ExtraInitialPackages returns the already-loaded *packages.Package for each of paths, found by walking the service's resolved import graph. It is how the openapi wrapper-descent horizon widening reaches a client package's bodies: the loader already type-checked the whole transitive import closure (loadMode carries NeedDeps|NeedSyntax|NeedTypesInfo), but ssautil.Packages builds function bodies only for the INITIAL (service) packages, so a separate-module client package is a bodiless external declaration until it is re-offered to ssabuild.Build as an extra initial package — which is exactly what these results feed.

A package already in s.Packages is EXCLUDED: the service's own first-party packages (a same-module declared client) are already initial and already built, so re-listing one would be a redundant — and, as a duplicate initial, harmful — entry. The result is sorted by PkgPath so the downstream initial-package order is deterministic.

A path with no loaded package is SILENTLY OMITTED, never an error: a declared client package that is not in the service's import graph can never be called by the service, so widening it would materialize bodies nothing reaches. Downstream the descent then finds nothing and the call stays disclosed — fail-closed degradation, mirroring how a mistyped plain classify hint package silently never matches today. Returning an error would instead fail a run over a stale-but-harmless hint, the wrong direction.

Jump to

Keyboard shortcuts

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