fileset

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package fileset handles file path resolution and glob expansion.

Index

Constants

This section is empty.

Variables

View Source
var ErrNoPatterns = errors.New("fileset: no patterns provided")

ErrNoPatterns indicates that Resolve was invoked without any glob patterns.

Functions

This section is empty.

Types

type MemoryResolver

type MemoryResolver struct {
	// contains filtered or unexported fields
}

MemoryResolver implements Resolver for testing without filesystem.

func NewMemoryResolver

func NewMemoryResolver(base string, files map[string][]byte) *MemoryResolver

NewMemoryResolver creates a new MemoryResolver with the given files. Files should be a map of relative paths to content.

func (*MemoryResolver) AddFile

func (m *MemoryResolver) AddFile(path string, content []byte)

AddFile adds a file to the resolver.

func (*MemoryResolver) FileCount

func (m *MemoryResolver) FileCount() int

FileCount returns the number of files.

func (*MemoryResolver) ReadFile

func (m *MemoryResolver) ReadFile(path string) ([]byte, error)

ReadFile returns the content of an in-memory file.

func (*MemoryResolver) RemoveFile

func (m *MemoryResolver) RemoveFile(path string)

RemoveFile removes a file from the resolver.

func (*MemoryResolver) Resolve

func (m *MemoryResolver) Resolve(patterns []string) ([]string, error)

Resolve matches patterns against in-memory file paths.

type NoMatchError

type NoMatchError struct {
	Patterns []string
}

NoMatchError describes which patterns failed to yield any results.

func (NoMatchError) Error

func (e NoMatchError) Error() string

Error implements the error interface.

type PatternError

type PatternError struct {
	Pattern string
	Err     error
}

PatternError wraps syntax issues reported while evaluating a glob pattern.

func (PatternError) Error

func (e PatternError) Error() string

Error implements the error interface.

func (PatternError) Unwrap

func (e PatternError) Unwrap() error

Unwrap returns the underlying error.

type Resolver

type Resolver struct {
	// contains filtered or unexported fields
}

Resolver resolves glob patterns against an fs.FS and rewrites the discovered paths using a join function for deterministic, de-duplicated results.

func NewOSResolver

func NewOSResolver(base string) (Resolver, error)

NewOSResolver constructs a Resolver rooted at base that returns absolute OS paths for each match.

func NewResolver

func NewResolver(fsys fs.FS) Resolver

NewResolver constructs a Resolver against the provided filesystem without any path rewriting, preserving the original match names. Useful for tests.

func (Resolver) Resolve

func (r Resolver) Resolve(patterns []string) ([]string, error)

Resolve evaluates each glob pattern, accumulating matches, and returns a deterministically sorted list of de-duplicated paths.

Jump to

Keyboard shortcuts

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