fsscan

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2026 License: Apache-2.0 Imports: 5 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
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

func FindGitRepos(ctx context.Context, root string, opts Options) ([]string, bool)

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.

Types

type Options

type Options struct {
	// MaxDepth is the number of directory levels below root to descend.
	// Zero means DefaultMaxDepth.
	MaxDepth int
	// SkipDirs replaces the default set of pruned directory names.
	SkipDirs map[string]struct{}
}

Options tune a scan. The zero value is ready to use.

Jump to

Keyboard shortcuts

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