Documentation
¶
Overview ¶
Package fileglob provides a filesystem glob API.
Index ¶
- func ContainsMatchers(pattern string) bool
- func Glob(pattern string, opts ...OptFunc) ([]string, error)
- func MatchDirectoryAsFile(opts *globOptions)
- func MatchDirectoryIncludesContents(opts *globOptions)
- func MaybeRootFS(opts *globOptions)
- func QuoteMeta(opts *globOptions)
- func ValidPattern(pattern string) error
- type OptFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ContainsMatchers ¶ added in v0.3.0
ContainsMatchers determines whether the pattern contains any type of glob matcher. It will also return false if the pattern is an invalid expression.
func Glob ¶
Glob returns all files that match the given pattern in the current directory. If the given pattern indicates an absolute path, it will glob from `/` (or from the volume root, on Windows). If the given pattern starts with `../`, it will resolve to its absolute path and glob from `/`.
func MatchDirectoryAsFile ¶ added in v0.4.0
func MatchDirectoryAsFile(opts *globOptions)
MatchDirectoryAsFile makes a match on a directory match its name only.
Also check MatchDirectoryIncludesContents.
func MatchDirectoryIncludesContents ¶ added in v0.4.0
func MatchDirectoryIncludesContents(opts *globOptions)
MatchDirectoryIncludesContents makes a match on a directory match all files inside it as well.
This is the default behavior.
Also check MatchDirectoryAsFile.
func MaybeRootFS ¶ added in v1.0.1
func MaybeRootFS(opts *globOptions)
MaybeRootFS setups fileglob to walk from the root directory (/) or volume (on windows) if the given pattern is an absolute path.
Result will also be prepended with the root path or volume.
This is the default behavior, so this option is not needed anymore. It is kept for backwards compatibility.
func QuoteMeta ¶
func QuoteMeta(opts *globOptions)
QuoteMeta quotes all glob pattern meta characters inside the argument text. For example, QuoteMeta for a pattern `{foo*}` sets the pattern to `\{foo\*\}`.
func ValidPattern ¶ added in v0.3.0
ValidPattern determines whether a pattern is valid. It returns the parser error if the pattern is invalid and nil otherwise.
Types ¶
type OptFunc ¶ added in v0.2.0
type OptFunc func(opts *globOptions)
OptFunc is a function that allow to customize Glob.
func WithFs ¶
WithFs allows to provide another fs.FS implementation to Glob.
Patterns are always relative to the root of the given fs.FS, so this also disables the default root filesystem handling of absolute patterns.
func WriteOptions ¶ added in v1.0.1
WriteOptions write the current options to the given writer.