glob

package
v0.1.16 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2021 License: BSD-3-Clause Imports: 2 Imported by: 39

Documentation

Overview

Package glob defines a globbing syntax and implements matching routines.

Globs match a slash separated series of glob expressions.

// Patterns:
term ['/' term]*
term:
'*'         matches any sequence of non-Separator characters
'?'         matches any single non-Separator character
'[' [ '^' ] { character-range } ']'
// Character classes (must be non-empty):
c           matches character c (c != '*', '?', '\\', '[', '/')
'\\' c      matches character c
// Character-ranges:
c           matches character c (c != '\\', '-', ']')
'\\' c      matches character c
lo '-' hi   matches character c for lo <= c <= hi

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Element

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

Element represents a single element of a glob pattern.

func (*Element) FixedPrefix

func (m *Element) FixedPrefix() (string, bool)

FixedPrefix returns the unescaped fixed part of the pattern, and whether the prefix is the whole pattern. The fixed part does not contain any wildcards.

func (*Element) Match

func (m *Element) Match(segment string) bool

Match returns true iff this pattern element matches the given segment.

type Glob

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

Glob represents a slash separated path glob pattern.

func Parse

func Parse(pattern string) (*Glob, error)

Parse returns a new Glob.

func (*Glob) Empty

func (g *Glob) Empty() bool

Empty returns true if the pattern cannot match anything.

func (*Glob) Head

func (g *Glob) Head() *Element

Head returns an Element for the first element of the glob pattern.

func (*Glob) Len

func (g *Glob) Len() int

Len returns the number of path elements represented by the glob expression.

func (*Glob) Recursive

func (g *Glob) Recursive() bool

Recursive returns true if the pattern is recursive.

func (*Glob) Restricted

func (g *Glob) Restricted() bool

Restricted returns true if recursion is restricted (up to the caller to know what that means).

func (*Glob) SplitFixedElements

func (g *Glob) SplitFixedElements() ([]string, *Glob)

SplitFixedElements returns the part of the glob pattern that contains only fixed elements, and the glob that follows it.

func (*Glob) String

func (g *Glob) String() string

String returns the string representation of the glob pattern.

func (*Glob) Tail

func (g *Glob) Tail() *Glob

Tail returns the suffix of g starting at the second element.

Jump to

Keyboard shortcuts

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