Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GoFiles ¶
GoFiles discovers every .go file the Go build system would compile under srcRoot, honoring build constraints (//go:build), excluding ignored files (//go:build ignore) and CGO-conditional alternates the host doesn't pick.
Multi-module: walks for go.mod files (skipping vendor/, node_modules/, .git/, and testdata/), then runs packages.Load("./...") in each module directory. Returns relpaths from srcRoot in slash form, deduplicated, sorted lexicographically.
Tests:true is set so _test.go files included in pkg.GoFiles surface in the result — the parser indexes them; omitting them would surface as audit drift between the build oracle and what production parses.
When srcRoot contains no go.mod anywhere, returns an empty slice with no error (the caller's TS/Sol pipelines may still find files there).
Implementation: thin wrapper over GoPackagesMode(srcRoot, ModeFiles) so detect.GoFiles and detect.GoPackages share a single discovery oracle. (B1 introduced GoPackages so the Go parser can access types.Info; this keeps the file-list contract unchanged.)
func GoPackages ¶
GoPackages is shorthand for GoPackagesMode(srcRoot, ModeTypes) — the loaded-with-type-info variant. The Go parser uses this to walk Syntax trees alongside TypesInfo so concurrency analysis can resolve sync.Mutex receivers via types.Object identity rather than fragile name matching.
func GoPackagesMode ¶
func GoPackagesMode(srcRoot string, mode GoPackagesLoadMode) ([]*packages.Package, error)
GoPackagesMode runs packages.Load for every go.mod under srcRoot using the mode bits selected by `mode`. Returns the union of every module's loaded packages in load order. Per-module load failures are returned as errors (consistent with GoFiles' fail-fast behavior on Load errors, in contrast to per-package type-check failures which are tolerated).
Types ¶
type CKGIgnore ¶
type CKGIgnore struct {
// contains filtered or unexported fields
}
CKGIgnore is a gitignore-style matcher (no negations, no anchored leading slashes). Patterns ending in "/" match directories. Patterns containing "*" use filepath.Match.
func LoadCKGIgnore ¶
LoadCKGIgnore reads `.ckgignore` from root. Missing file is OK (returns empty matcher).
type GoPackagesLoadMode ¶
type GoPackagesLoadMode int
GoPackagesLoadMode selects how much info packages.Load is asked to produce. ModeFiles is the cheap mode used by GoFiles for discovery only; ModeTypes adds full TypesInfo + Syntax (required by the Go concurrency pass to resolve sync.Mutex receivers — name-only matching produces false positives on user-defined types named "Mutex").
const ( // ModeFiles loads names + file lists only (cheap, GoFiles fingerprint). ModeFiles GoPackagesLoadMode = iota // ModeTypes loads everything ModeFiles does plus parsed Syntax, // resolved Types, and TypesInfo. ~10x slower on large modules; use // only when the consumer needs go/types resolution (concurrency pass). ModeTypes )