inventory

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2026 License: Apache-2.0 Imports: 11 Imported by: 0 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 inventory walks regular source files within a hard root boundary and records reported skips. Fixed cache and dependency directories, unreadable directories, non-regular files, refused symlinks, source classification, and resource limits may omit files. Generated-file claims in names or contents and arbitrary dot paths do not.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Entry

type Entry struct {
	// Path is relative to the scan root, using forward slashes, so results
	// are stable across platforms
	Path string
	Abs  string
	Size int64
	Lang language.ID
	// MaxBytes truncates an oversized file instead of dropping it. The limit
	// still downgrades coverage.
	MaxBytes int64
}

Entry is one file worth parsing

type Limits

type Limits struct {
	MaxFileSize     int64 // truncate a single file larger than this
	MaxTotalSize    int64 // stop once the sum of included file sizes reaches this
	MaxFiles        int   // stop once this many files have been included
	MaxSymlinkDepth int   // longest chain of directory symlinks followed
	MaxDirDepth     int   // longest chain of plain (non-symlink) directories descended
}

Limits bound how much of a hostile tree the walk will look at

func DefaultLimits

func DefaultLimits() Limits

DefaultLimits are generous enough for a real repository and small enough that a crafted tree (a symlink loop, a directory of many huge files) cannot turn a scan into a memory exhaustion attack

type Result

type Result struct {
	Root     string
	Files    []Entry
	Coverage model.Coverage
}

Result is what one walk found

func Walk

func Walk(ctx context.Context, root string, limits Limits) (*Result, error)

Walk collects the files under root that a language adapter claims, respecting root as a hard boundary: a symlink that resolves outside root is skipped and never followed. A deadline stops the walk as a recorded limit rather than returning an apparently complete partial list.

Jump to

Keyboard shortcuts

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