glob

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2026 License: MIT Imports: 6 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 glob matches slash-separated paths against glob patterns: "*" and "?" stay within one path element, "**" as a whole element matches any number of elements (none included), "[...]" is a character class ("[!...]" negated) and "{a,b}" lists alternatives. Every MatrixClaw path pattern goes through it.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Base

func Base(pattern string) string

Base is the leading directories of pattern that hold no wildcard, such as "src/app" for "src/app/**/*.ts"; a walk for the pattern can start there.

func Match

func Match(pattern string, path string) bool

Match reports whether path matches pattern, hidden names included; compiled patterns are cached, so pattern should come from a small set such as rules.

Types

type Ignore

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

Ignore is a stack of .gitignore rules; later rules win, as in git. The zero Ignore ignores nothing.

func (Ignore) Add

func (ig Ignore) Add(base string, content []byte) Ignore

Add returns ig with the rules of a .gitignore file whose patterns are relative to base, a slash path; ig itself is unchanged.

func (Ignore) Ignored

func (ig Ignore) Ignored(path string, dir bool) bool

Ignored reports whether the rules leave out path, a slash path in the same space as the bases. Only path itself is checked, not its parents.

type Pattern

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

Pattern is a compiled glob.

func Compile

func Compile(pattern string) *Pattern

Compile compiles pattern. It never fails: an unclosed bracket or brace and a class Go cannot express are literal text.

func CompileFilter

func CompileFilter(pattern string) *Pattern

CompileFilter compiles a filter pattern the way ripgrep and .gitignore read one: a pattern with no slash matches a name at any depth.

func (*Pattern) Match

func (p *Pattern) Match(path string) bool

Match reports whether path matches; wildcards match hidden names too.

func (*Pattern) MatchVisible

func (p *Pattern) MatchVisible(path string) bool

MatchVisible is Match where wildcards skip hidden names (a leading dot), so only an element that starts with a dot itself, such as ".github", names one.

func (*Pattern) Reaches

func (p *Pattern) Reaches(dir string) bool

Reaches reports whether a path below dir may match visibly, so a walk can skip a directory that cannot hold a match.

Jump to

Keyboard shortcuts

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