expr

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package expr defines the supported types of match expressions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache struct {
	*sync.RWMutex
	// contains filtered or unexported fields
}

Cache defines a memoized data structure that associates regular expression patterns with their compiled regexp.Regexp representations. It contains synchronization primitives for safely accessing elements concurrently from multiple goroutines.

From a (Expr).Match context, it enables reuse of regexp.Regexp objects across multiple calls without having to recompile the pattern string each time.

func (*Cache) Get

func (c *Cache) Get(pattern string) (*regexp.Regexp, error)

Get returns a compiled regexp.Regexp object for the given regular expression string pattern. The pattern will be compiled and added to the receiver Cache if it is not present. This method is safe to call from multiple goroutines concurrently.

type ErrInvalidExpr

type ErrInvalidExpr Expr

Error types specific to package expr that may be returned by one of its exported functions or methods. Use type assertion to determine the type of error and the interface func Error() for a descriptive error message.

func (ErrInvalidExpr) Error

func (e ErrInvalidExpr) Error() string

Error returns a descriptive error string for the receiver ErrInvalidExpr e.

type Expr

type Expr int

Expr enumerates all supported types of match expressions.

const (
	Fixed  Expr = iota // Match entire file names verbatim
	Glob               // Match using standard Go path.Match semantics
	Regexp             // Match using standard Go regexp.Regexp semantics

)

Enumerated constants of type Expr.

func (Expr) Match

func (e Expr) Match(pattern string, s string) (matched bool, err error)

Match reports whether the given string s matches the given string pattern according to the semantics of the receiver Expr e. Match is safe to call from multiple goroutines concurrently.

func (Expr) String

func (e Expr) String() string

String returns a string representation of the receiver Expr e.

Jump to

Keyboard shortcuts

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