Documentation ¶
Overview ¶
Package path provides simple abstractions over the os/path package of the go standard library. It should be used in conjunction with the shutil/fs package
Index ¶
- Variables
- func GatherAll(dirPath string) (paths []string, err error)
- func IsType(l Like, t Type) (b bool)
- func MustBeType(l Like, t Type) (err error)
- type Dir
- type ErrDuringOp
- type Extension
- type Extensions
- type File
- type Filter
- type GatherPaths
- func (g GatherPaths) GatherPatterns(p Patterns) (outPaths Paths, err error)
- func (g GatherPaths) GetPaths() (p []string)
- func (g *GatherPaths) PatternVisitor(prefix *string, path string, kind PatternKind) (err error)
- func (g GatherPaths) VisitPattern(path string, kind PatternKind) (paths []string, err error)
- type Glob
- type GlobMethods
- type InvalidPath
- type Like
- type ListMode
- type Logger
- type Methods
- type MismatchedType
- type MissingExtHandling
- type MissingExtension
- type OpKind
- type Operation
- type PathKinds
- type PathLister
- type Paths
- type Pattern
- type PatternKind
- type PatternLister
- type PatternMap
- type Patterns
- type PatternsConfig
- type PatternsParser
- type Raw
- type Ref
- type SelectedExtensions
- type SplitMethods
- type StdMethods
- func (StdMethods) Glob(pattern string) ([]string, error)
- func (StdMethods) HasPrefix(p, prefix string) bool
- func (StdMethods) IsAbs(path string) bool
- func (StdMethods) Join(parts ...string) string
- func (StdMethods) Match(pattern, name string) (bool, error)
- func (StdMethods) Rel(base, target string) (string, error)
- func (StdMethods) Split(path string) (dir, file string)
- func (StdMethods) SplitParts(path string) []string
- func (StdMethods) UnaryOp(op UnaryOp, path string) (string, error)
- type Stringer
- type Type
- type UnaryMethods
- type UnaryOp
- type Visitor
- type WalkMethods
Constants ¶
This section is empty.
Variables ¶
var DefaultPathKinds = PathKinds{ "glob": PathPattern, "file": PathFile, }
var ErrExtensionMissing = fmt.Errorf("path/filter.go: extension could not be determined or empty")
Functions ¶
func MustBeType ¶
Types ¶
type Dir ¶
type Dir struct {
// contains filtered or unexported fields
}
func (Dir) ExpectedType ¶
func (Dir) PathString ¶
type ErrDuringOp ¶
type ErrDuringOp struct { // Path that was under operation. Path Like // The kind of operation that was carried out. Op Operation // contains filtered or unexported fields }
ErrDuringOp wraps and error that happened during an operation.
func OpError ¶
func OpError(like Like, op OpKind, err error) (e ErrDuringOp)
OpError is convenience function for generating an ErrDuringOp struct.
func (ErrDuringOp) Error ¶
func (e ErrDuringOp) Error() (s string)
func (ErrDuringOp) Unwrap ¶
func (e ErrDuringOp) Unwrap() (err error)
type Extension ¶
type Extension struct {
// contains filtered or unexported fields
}
func GetExtension ¶
func MustGetExtension ¶
func NewExtension ¶
type Extensions ¶
type Extensions struct { Extensions mapping.StringSet Mode filter.SelectMode HandleMissing MissingExtHandling }
func (Extensions) ToFilter ¶
func (e Extensions) ToFilter(l zerolog.Logger) (se SelectedExtensions)
type File ¶
type File struct {
// contains filtered or unexported fields
}
func (File) ExpectedType ¶
func (File) PathString ¶
type GatherPaths ¶
type GatherPaths struct {
// contains filtered or unexported fields
}
func NewPathGatherer ¶
func NewPathGatherer(fsys fs.FS, l zerolog.Logger) (g GatherPaths)
func (GatherPaths) GatherPatterns ¶
func (g GatherPaths) GatherPatterns(p Patterns) (outPaths Paths, err error)
func (GatherPaths) GetPaths ¶
func (g GatherPaths) GetPaths() (p []string)
func (*GatherPaths) PatternVisitor ¶
func (g *GatherPaths) PatternVisitor(prefix *string, path string, kind PatternKind) (err error)
func (GatherPaths) VisitPattern ¶
func (g GatherPaths) VisitPattern(path string, kind PatternKind) (paths []string, err error)
type GlobMethods ¶
type InvalidPath ¶
type InvalidPath struct { // The invalid Path. Path Stringer }
InvalidPath is returned from ToValid of Path is not valid.
func (InvalidPath) Error ¶
func (i InvalidPath) Error() (s string)
type Methods ¶
type Methods interface { UnaryMethods WalkMethods GlobMethods SplitMethods Join(parts ...string) string IsAbs(path string) bool HasPrefix(p, prefix string) bool Rel(basepath, targpath string) (string, error) }
type MismatchedType ¶
type MismatchedType struct {
Expected, Got Type
}
func (MismatchedType) Error ¶
func (m MismatchedType) Error() (s string)
type MissingExtHandling ¶
type MissingExtHandling int
const ( MissingExtSkip MissingExtHandling = iota MissingExtError )
type MissingExtension ¶
type MissingExtension struct {
PathString Stringer
}
func (MissingExtension) Error ¶
func (m MissingExtension) Error() (s string)
type OpKind ¶
type OpKind int
OpKind denotes different operations being carried out on paths, files, directories
func (OpKind) PathDescribe ¶
PathDescribe provides an explanitory message.
type Operation ¶
type Operation interface { // PathDescribe returns an explanatory message formatted using Path. PathDescribe(Like) string }
Operation represents a fallibe operation tha can be carried out on a filepath.
type PathKinds ¶
type PathKinds map[string]PatternKind
type PathLister ¶
type Pattern ¶
type PatternLister ¶
type PatternLister struct {
// contains filtered or unexported fields
}
func (PatternLister) ListPaths ¶
func (pl PatternLister) ListPaths() (paths []string, err error)
type PatternMap ¶
func (PatternMap) ToPatterns ¶
func (pm PatternMap) ToPatterns(fsys fs.FS, parser PatternsParser) (p Patterns, err error)
type PatternsConfig ¶
func NewPatternsConfig ¶
func NewPatternsConfig(sep string) (p PatternsConfig)
func (PatternsConfig) ParsePattern ¶
func (pc PatternsConfig) ParsePattern(fsys fs.FS, patternLine string) (s string, k PatternKind, err error)
type PatternsParser ¶
type Raw ¶
type Raw struct {
// contains filtered or unexported fields
}
func (Raw) ExpectedType ¶
func (Raw) PathString ¶
type SelectedExtensions ¶
type SelectedExtensions struct {
// contains filtered or unexported fields
}
func (SelectedExtensions) FilterPath ¶
func (s SelectedExtensions) FilterPath(p string) (b bool, err error)
func (SelectedExtensions) FilterPaths ¶
func (s SelectedExtensions) FilterPaths(bools filter.Bools, paths []string) (err error)
type SplitMethods ¶
type StdMethods ¶
type StdMethods struct{}
func GetStdMethods ¶
func GetStdMethods() *StdMethods
func (StdMethods) HasPrefix ¶
func (StdMethods) HasPrefix(p, prefix string) bool
func (StdMethods) IsAbs ¶
func (StdMethods) IsAbs(path string) bool
func (StdMethods) Join ¶
func (StdMethods) Join(parts ...string) string
func (StdMethods) Split ¶
func (StdMethods) Split(path string) (dir, file string)
func (StdMethods) SplitParts ¶
func (StdMethods) SplitParts(path string) []string
type UnaryMethods ¶
type UnaryOp ¶
type UnaryOp int
ENUM(
Abs Clean Dir EvalSymlinks Ext FromSlash ToSlash VolumeName
)
const ( // UnaryOpAbs is a UnaryOp of type Abs. UnaryOpAbs UnaryOp = iota // UnaryOpClean is a UnaryOp of type Clean. UnaryOpClean // UnaryOpDir is a UnaryOp of type Dir. UnaryOpDir // UnaryOpEvalSymlinks is a UnaryOp of type EvalSymlinks. UnaryOpEvalSymlinks // UnaryOpExt is a UnaryOp of type Ext. UnaryOpExt // UnaryOpFromSlash is a UnaryOp of type FromSlash. UnaryOpFromSlash // UnaryOpToSlash is a UnaryOp of type ToSlash. UnaryOpToSlash // UnaryOpVolumeName is a UnaryOp of type VolumeName. UnaryOpVolumeName )
func ParseUnaryOp ¶
ParseUnaryOp attempts to convert a string to a UnaryOp.
func (UnaryOp) MarshalText ¶
MarshalText implements the text marshaller method.
func (*UnaryOp) UnmarshalText ¶
UnmarshalText implements the text unmarshaller method.