fn

package
v0.0.0-...-9d95335 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2024 License: MIT Imports: 6 Imported by: 5

Documentation

Index

Constants

View Source
const Separator = os.PathSeparator

Variables

View Source
var ErrBadPattern = errors.New("syntax error in pattern")

ErrBadPattern indicates a pattern was malformed.

Functions

func GetFuncName

func GetFuncName(i interface{}) string

GetFuncName returns the func name of a func.

func Match

func Match(pattern, name string, matchOptions ...MatchOptionsFn) (matched bool)

func MatchE

func MatchE(pattern, name string, matchOptions ...MatchOptionsFn) (matched bool, err error)

Match reports whether name matches the shell file name pattern in case insensitive for non-pattern parts. The pattern syntax is:

pattern:
	{ term }
term:
	'*'         matches any sequence of non-Separator characters
	'?'         matches any single non-Separator character
	'[' [ '^' ] { character-range } ']'
	            character class (must be non-empty)
	c           matches character c (c != '*', '?', '\\', '[')
	'\\' c      matches character c

character-range:
	c           matches character c (c != '\\', '-', ']')
	'\\' c      matches character c
	lo '-' hi   matches character c for lo <= c <= hi

Match requires pattern to match all of name, not just a substring. The only possible returned error is ErrBadPattern, when pattern is malformed.

On Windows, escaping is disabled. Instead, '\\' is treated as path separator.

Types

type MatchOptions

type MatchOptions struct {
	CaseInsensitive bool
}

type MatchOptionsFn

type MatchOptionsFn func(*MatchOptions)

func WithCaseSensitive

func WithCaseSensitive(v bool) MatchOptionsFn

type MatchOptionsFns

type MatchOptionsFns []MatchOptionsFn

func (MatchOptionsFns) CreateOptions

func (f MatchOptionsFns) CreateOptions() (options MatchOptions)

Jump to

Keyboard shortcuts

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