Skip to content
internal/scan
Edit
On this page

The directory walker and its worker pool: traversal filters, per-file classification and LOC counting, and deterministic per-format aggregation.

#internal/scan

#internal/scan

Package scan walks a directory tree, classifies files via a worker pool, and aggregates per-format statistics.

#SingletonsGroup

Go go
const SingletonsGroup = "(singletons)"

SingletonsGroup is the format name of the pseudo-group produced by CollapseSingletons.

#IgnoredInclude

Go go
const IgnoredInclude = "include"

Values for Options.Ignored.

#IgnoredExclude

Go go
const IgnoredExclude = "exclude"

#IgnoredOnly

Go go
const IgnoredOnly    = "only"

#HiddenInclude

Go go
const HiddenInclude = "include"

Values for Options.Hidden.

#HiddenExclude

Go go
const HiddenExclude = "exclude"

#TypeText

Go go
const TypeText   = "text"

Values for Options.TypeFilter.

#TypeBinary

Go go
const TypeBinary = "binary"

#TypeBoth

Go go
const TypeBoth   = "both"

#FormatsRaw

Go go
const FormatsRaw       = classify.FormatsRaw

Values for Options.Formats.

#FormatsCanonical

Go go
const FormatsCanonical = classify.FormatsCanonical

#StatNames

Go go
var StatNames = []string{

Stat names accepted by --stats (canonical column order).

#Options

Go go
type Options struct

Options configures a scan.

#Summary

Go go
type Summary struct

Summary holds the tree-wide summary statistics.

#Group

Go go
type Group struct

Group is the aggregate statistics for one format.

#Result

Go go
type Result struct

Result is the outcome of a scan. Groups are ordered by format name ascending; callers apply their own sort.

#IsLOCStat

Go go
func IsLOCStat(name string) bool

IsLOCStat reports whether name is one of the LOC stat names.

#SortGroups

Go go
func SortGroups(groups []Group, keys []string, desc bool)

SortGroups sorts groups in place by the given keys ("format" or a stat name) in precedence order, all in the same direction (desc when desc is true). Ties are broken by format name ascending (case-insensitive, then case-sensitive) so the output is deterministic.

#CollapseSingletons

Go go
func CollapseSingletons(groups []Group) []Group

CollapseSingletons merges all groups with exactly one file into a single "(singletons)" pseudo-group: count is the number of merged groups, sizes are aggregated over all merged groups, and LOC values are aggregated over the text merged groups only. The input is not modified.

#Scan

Go go
func Scan(opts Options) (*Result, error)

Scan walks opts.Root and returns aggregated statistics. It returns an error only if the root itself cannot be read; unreadable entries below the root are counted in Summary.Unreadable instead.

#ignoreMatcher.Match

Go go
func (im *ignoreMatcher) Match(rel string, isDir bool) bool

Match reports whether the slash-separated path relative to the scan root is gitignored.

More tools from this site

  • claudestream Drive Claude Code from Python: run it as a subprocess and read its output as typed events, with async and sync sessions, sandbox policies, and tools you define in Python
  • claudewheel A TUI Claude Code Launcher that lets you have more than one profile, manage sessions lifecycle, pick the exact CC version, model to use (even older unlisted ones), pick which GitHub account to use, etc.
  • fastware A batteries-included ASGI framework: msgspec JSON, a managed Granian server, dependency injection, SSE, WebSockets, auth, and a test client
  • go-toml-edit Zero-dep TOML editing library for Go with comment preservation
  • howmuchleft The fastest Claude Code statusline: context window, 5-hour, and weekly limit usage as three customizable gradient bars, rendering in about 6 ms
  • orxtra
  • pgdesign
  • predraw Declarative rendering pipeline: describe a scene in JSON and get SVG, PNG and WebP out, with light and dark style tokens, reusable components and text converted to path outlines
  • reposummary Turn a git repository's history into a Markdown journal: pick a time window or revision range and get a readable digest of what changed, optionally narrated by an LLM
  • rlsbl Release orchestration and project scaffolding CLI that bumps versions, validates a structured JSONL changelog, tags only the commit CI verified, and publishes to npm, PyPI, Go and more
  • safegit git wrapper CLI that gives each commit its own temporary index and retries ref updates on conflict, so concurrent agents share one repository
  • saferm Command-line replacement for rm that archives every deletion with a mandatory reason and the context it ran in, so deleted files can be listed, inspected and restored
  • selfdoc Static Site Generator that builds a project's documentation site directly from its source code, so the docs can never drift from the code they describe, with SEO/AEO, first-class blog, search, and cross-project linking built in
  • strictcli
  • stricttest An always-on test-isolation floor: a pytest plugin and a Go env-hygiene module that make a test suite structurally unable to reach real credentials, the real HOME, the network, or the development repository.
  • wesktop A Python framework that turns an ASGI web app into a desktop application, serving it from a local Granian server and displaying it in a native OS window via pywebview
Search