glob

package module
v0.0.0-...-334abef Latest Latest
Warning

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

Go to latest
Published: May 4, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Glob

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

A Glob stores a shell filename pattern for matching.

func Parse

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

Parse parses shell filename pattern and returns a new Glob or an error if the pattern is invalid. Precede the pattern with '!' to negate the Glob.

Parse("*.go")  // Matches any string ending with ".go"
Parse("!*.go") // Matches any string *not* ending with ".go"

func (*Glob) Get

func (g *Glob) Get() any

Get returns Glob *g and exists to satisfy the flag.Getter interface.

func (*Glob) Kind

func (g *Glob) Kind() MatchKind

Kind returns the Glob's MatchKind.

func (*Glob) Match

func (g *Glob) Match(path string) bool

Match returns if the Glob matches path.

func (*Glob) Negated

func (g *Glob) Negated() bool

Negated returns if the Glob is negated.

func (*Glob) Pattern

func (g *Glob) Pattern() string

Pattern returns the pattern the Glob was created with.

func (*Glob) Set

func (g *Glob) Set(pattern string) error

Sets the Glob's pattern to pattern and exists to implement the flag.Value and pflag.Value interfaces.

func (*Glob) String

func (g *Glob) String() string

func (*Glob) Type

func (g *Glob) Type() string

Type implements pflag.Value.

type GlobSet

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

A GlobSet is an ordered set of Globs. When matching the Glob given later takes precedence.

func NewGlobSet

func NewGlobSet(patterns ...string) (*GlobSet, error)

NewGlobSet returns a new GlobSet.

func (*GlobSet) Add

func (s *GlobSet) Add(g *Glob)

Add appends Glob g to the GlobSet.

func (*GlobSet) Append

func (s *GlobSet) Append(pattern string) error

Append appends pattern to the GlobSet and exists to implement the pflag.SliceValue interface.

func (*GlobSet) Get

func (s *GlobSet) Get() any

Get returns GlobSet *s and exists to satisfy the flag.Getter interface.

func (*GlobSet) GetSlice

func (s *GlobSet) GetSlice() []string

GetSlice returns a list of the GlobSet's patterns and exists to implement the pflag.SliceValue interface.

func (*GlobSet) Match

func (s *GlobSet) Match(path string) bool

Match returns if the GlobSet matches path. If multiple Globs match path, the glob given later takes precedence.

func (*GlobSet) Parse

func (s *GlobSet) Parse(pattern string) error

Parse parses shell filename pattern and appends it to the GlobSet.

func (*GlobSet) Replace

func (s *GlobSet) Replace(patterns []string) error

Replace replaces all the GlobSet's patterns and exists to implement the pflag.SliceValue interface.

func (*GlobSet) Set

func (s *GlobSet) Set(pattern string) error

Sets the GlobSet's pattern to pattern, removing any existing patterns and exists to implement the flag.Value and pflag.Value interfaces.

func (*GlobSet) String

func (s *GlobSet) String() string

func (*GlobSet) Type

func (s *GlobSet) Type() string

Type implements pflag.Value.

type MatchKind

type MatchKind int32

MatchKind is the kind of match used by Globs.

const (
	MatchGlob     MatchKind = iota // match with filepath.Glob (`*.[ch]`)
	MatchPrefix                    // match only prefix (`main.*`)
	MatchSuffix                    // match only suffix (`*.go`)
	MatchContains                  // match if path contains pattern (`*main*`)
	MatchExact                     // exact match (`main.go`)
)

func (MatchKind) String

func (m MatchKind) String() string

Jump to

Keyboard shortcuts

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