Documentation
¶
Overview ¶
Package fsscan finds files by extension under a directory tree without ever doing unbounded work.
Source trees routinely contain millions of files under dependency and build directories. A scan here is bounded three ways: heavy directories are pruned, depth is capped, and the walk stops when its context ends.
Index ¶
Constants ¶
const DefaultMaxDepth = 6
DefaultMaxDepth is how many directory levels below the root are searched.
Variables ¶
This section is empty.
Functions ¶
func FindByExtension ¶
func FindByExtension(ctx context.Context, root string, extensions []string, opts Options) (map[string][]string, bool)
FindByExtension returns the paths under root whose file name ends with one of the given extensions (case-insensitive, leading dot included, e.g. ".sqlite"), grouped by the extension that matched.
It never returns an error: unreadable directories are skipped, and when ctx ends the results gathered so far are returned. The second return value reports whether the scan covered the whole (pruned, depth-capped) tree.
func FindGitRepos ¶
FindGitRepos returns the root directories of git repositories under root, in lexical order.
A directory counts as a repository when it contains a ".git" entry (a directory, or a file as used by worktrees and submodules). The search does not descend into a repository once found: submodules and linked worktrees are part of their parent project, and skipping repository contents is what keeps the walk fast on large source trees.
Like FindByExtension it is bounded by depth and by ctx, never fails, and reports whether the search was complete.