dirsource

package
v0.4.4 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package dirsource implements the filesystem source (ARCHITECTURE.md §7): streaming enumeration with a nested per-directory .gitignore/.airomignore stack, non-overridable default skips, user --ignore globs, and an ignore-honoring resolver for the phase-2 pull API. Symlinks are never followed (which also forecloses cycles); non-regular files are skipped; permission failures below the root degrade to Unknown records (invariant P6) while an unreadable root is a fatal source-acquisition failure.

Concurrency: Walk keeps all traversal state walk-local, so concurrent Walks — including the Resolver's pulls, which run in parallel during phase 2 (§8) — are safe.

Package dirsource implements the local-directory Source (ARCHITECTURE.md §7): fastwalk enumeration with a per-directory nested .gitignore stack (gocodewalker semantics), .airomignore, and default skips (.git, node_modules, vendor, virtualenvs); an 8 KB NUL-sniff for binary detection; symlink cycles guarded by (dev, inode); and permission errors degraded to Unknowns, never fatal (invariant P6).

Directory trees are the seekable easy case of the Source contract, so ReaderAt is fully supported here. dirsource is also the delegation target for gitsource, which scans its shallow clone as a plain filesystem.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Options

type Options struct {
	// IgnoreGlobs are user --ignore doublestar patterns over root-relative
	// slash paths, applied on top of the ignore-file stack.
	IgnoreGlobs []string
}

Options configures a directory source.

type Source

type Source struct {
	// contains filtered or unexported fields
}

Source is the dir implementation of source.Source.

func New

func New(root string, opts Options) (*Source, error)

New validates the target and prepares a directory source.

func (*Source) Close

func (s *Source) Close() error

Close is a no-op: dir sources hold no resources between walks.

func (*Source) ID

func (s *Source) ID() string

ID is the cache-key identity of this source.

func (*Source) Info

func (s *Source) Info() source.Info

Info returns the provenance root for the scan output.

func (*Source) Kind

func (s *Source) Kind() source.Kind

Kind reports the source kind ("dir").

func (*Source) Name

func (s *Source) Name() string

Name returns the absolute scan root.

func (*Source) Resolver

func (s *Source) Resolver() source.Resolver

Resolver returns the pull-style query API. Every method honors the same ignore rules as Walk — a phase-2 detector can never see a file phase 1 could not — and confines access to the scan root even through symlinks. Safe for concurrent use (walk state is per-invocation).

func (*Source) Walk

func (s *Source) Walk(ctx context.Context, fn source.WalkFunc) error

Walk streams regular, non-ignored files, then publishes the walk's Unknown records. Entries are emitted from multiple goroutines (fastwalk's internal parallelism); Walk returns only after every callback has returned, so a caller may close a channel after Walk without racing sends.

func (*Source) WalkStats added in v0.4.2

func (s *Source) WalkStats() source.WalkStats

WalkStats returns the exclusion accounting of the most recent top-level Walk. Like WalkUnknowns, Resolver pulls never clobber it.

func (*Source) WalkUnknowns

func (s *Source) WalkUnknowns() []source.Unknown

WalkUnknowns returns walk-level failures published by the most recent top-level Walk. Resolver pulls never clobber these.

Jump to

Keyboard shortcuts

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