walker

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2026 License: MIT Imports: 8 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 walker provides a gitignore-aware file walker that returns all source files worth indexing from a given root directory.

Index

Constants

View Source
const (
	ReasonLarge         = "file exceeds max_file_size"
	ReasonBrokenSymlink = "broken symlink"
	ReasonSymlinkEscape = "symlink resolves outside the root"
	ReasonSymlinkDir    = "symlinked directory not followed"
	ReasonNotRegular    = "not a regular file"
	ReasonUnreadable    = "unreadable"
	ReasonMissingRoot   = "configured root not found"
	ReasonRootEscape    = "configured root resolves outside the repo"
)

Skip reasons reported in Result.Skipped.

Variables

This section is empty.

Functions

func Walk

func Walk(root string, extraIgnore []string) ([]string, error)

Walk traverses root and returns a sorted slice of relative paths for all source files that are not excluded by ignore rules or alwaysIgnoreDirs. extraIgnore is an optional list of additional gitignore-style patterns; it may be nil. Use WalkWith for roots, include globs, size caps and skip reports.

Types

type Options added in v0.5.0

type Options struct {
	ExtraIgnore []string // gitignore-style patterns skipped in addition to ignore files
	Include     []string // when non-empty, only files matching one of these globs are kept
	Roots       []string // scan only these subdirectories (relative, slash-separated)
	MaxFileSize int64    // files larger than this many bytes are skipped; 0 disables
}

Options tunes WalkWith.

type Result added in v0.5.0

type Result struct {
	Files   []string // sorted, slash-separated, relative to the walk root
	Skipped []Skip   // sorted by path
}

Result is the outcome of a walk.

func WalkWith added in v0.5.0

func WalkWith(root string, o Options) (*Result, error)

WalkWith is the full-featured walker. It never follows directory symlinks, rejects file symlinks that are broken or leave the root, skips oversized files, and honours .gitignore (nested too) plus .stacklitignore.

type Skip added in v0.5.0

type Skip struct {
	Path   string
	Reason string
}

Skip records one path the walker deliberately did not index.

Jump to

Keyboard shortcuts

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