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.

Search