Documentation
¶
Overview ¶
Package codebase builds a Codebase, a read-only view of one codebase, over a CodebaseSource: file selection, contents, pattern matches, the Go and YAML parsed forms and rendered charts. Every view is memoized on a Snapshot, so concurrent checks share one listing, one read and one parse of each file and one render of each chart for a run.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GeneratedHeader ¶
GeneratedHeader reports whether Go source carries the standard generated-code marker, a `// Code generated … DO NOT EDIT.` line before the package clause.
func GeneratedName ¶
GeneratedName reports whether a Go file's name marks it generated: protobuf and gRPC output, `_gen.go` / `.gen.go` files, `zz_generated` deep-copy files and `mock_*.go` mocks.
func Glob ¶
Glob reports whether the slash-separated path p matches pattern, where `**` matches any number of whole segments (including none) and every other segment matches as path.Match does. A malformed segment matches nothing.
func Matches ¶
func Matches(sel types.FileSelector, p string) bool
Matches reports whether sel selects path on its path alone: Roots, Paths, Globs, Exts and Exclude (TrackedOnly and IncludeGenerated need the file, not its path).
func New ¶
func New( src interfaces.CodebaseSource, snap *Snapshot, renderer interfaces.Renderer, ) interfaces.Codebase
New returns the Codebase over src, memoized on snap; renderer may be nil.
Types ¶
type Snapshot ¶
type Snapshot struct {
// contains filtered or unexported fields
}
Snapshot memoizes a run's views of one repository: every keyed value is computed once and shared by concurrent callers for the snapshot's life. A Snapshot is safe for concurrent use; construct it with NewSnapshot.
func NewSnapshot ¶
NewSnapshot returns an empty snapshot identified by key.
func (*Snapshot) Memo ¶
func (s *Snapshot) Memo[T any]( ctx context.Context, key string, build func(context.Context) (T, error), ) (T, error)
Memo returns the value build computes for key, running build once per key: callers that arrive while it runs wait for it (or for their own ctx), and later callers get the stored value. A build error is stored and returned to every caller, except a context cancellation or deadline, which is returned to its caller only so the next caller builds afresh. A build that panics is CodeInternal for its caller and the callers waiting on it, and is not stored, so a later caller builds again. A key reused with a different T is CodeInternal.