Documentation ¶
Index ¶
- func ReadDir(dirname string) ([]os.FileInfo, error)
- type FileInfoIterator
- type FileIterator
- type IteratorEmptyError
- type Line
- type LineIterator
- type MultiFileLineIterator
- type NegativeRegexpLineIteratorWrapper
- type PrefixedPathFileInfo
- func (f PrefixedPathFileInfo) IsDir() bool
- func (f PrefixedPathFileInfo) ModTime() time.Time
- func (f PrefixedPathFileInfo) Mode() os.FileMode
- func (f PrefixedPathFileInfo) Name() string
- func (f PrefixedPathFileInfo) Size() int64
- func (f PrefixedPathFileInfo) String() string
- func (f PrefixedPathFileInfo) Sys() interface{}
- type RegexpLineIteratorWrapper
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type FileInfoIterator ¶
type FileInfoIterator interface { // Next returns the next available value in the iterator. If there are no // more values then implementations must return an instance of // IteratorEmptyError as the error. Next() (os.FileInfo, error) }
FileInfoIterator is an interface that represents an iterator that produces os.FileInfo items.
type FileIterator ¶
type FileIterator struct {
// contains filtered or unexported fields
}
FileIterator is an implementation of the iterator pattern that consumes a directory path and emits only the os.FileInfo objects is the recursive directory tree that have IsDir() return true.
func NewFileIter ¶
func NewFileIter(dirname string) (*FileIterator, error)
NewFileIter initialises the iterator and sets up the internal state.
type IteratorEmptyError ¶
type IteratorEmptyError struct{}
IteratorEmptyError represents the error state where the iterator contains no more values to return and should not be iterated on any more.
func (IteratorEmptyError) Error ¶
func (e IteratorEmptyError) Error() string
func (IteratorEmptyError) String ¶
func (e IteratorEmptyError) String() string
type Line ¶
type Line struct { // Name is the file path currently being iterated over. Name string // Number is the line number that the text falls on. Number uint64 // Text is the content plucked from a file. Text string }
Line represents a single line from a file.
type LineIterator ¶
type LineIterator interface { // Next draws the next value from the iterator. If there are no more lines // left in the iterator then an implementation must return IteratorEmptyError. Next() (Line, error) }
LineIterator is an interface that represents a producer of lines from a file.
type MultiFileLineIterator ¶
type MultiFileLineIterator struct {
// contains filtered or unexported fields
}
MultiFileLineIterator consumes a FileInfoIterator implementation and produces lines from all files produced by the contained iterator.
func NewMultiFileLineIterator ¶
func NewMultiFileLineIterator(fileIterator FileInfoIterator) (*MultiFileLineIterator, error)
NewMultiFileLineIterator generates an initalised MultiFileLineIterator that reads from the given FileInfoIterator.
func (*MultiFileLineIterator) Next ¶
func (i *MultiFileLineIterator) Next() (Line, error)
Next produces the next line from one of the files provided by the internal iterator object.
type NegativeRegexpLineIteratorWrapper ¶
type NegativeRegexpLineIteratorWrapper struct {
// contains filtered or unexported fields
}
NegativeRegexpLineIteratorWrapper filters all lines from the wrapped LineIterator based on not matchign a regexp search.
func NewNegativeRegexpLineIteratorWrapper ¶
func NewNegativeRegexpLineIteratorWrapper(pattern *regexp.Regexp, iterator LineIterator) (*NegativeRegexpLineIteratorWrapper, error)
NewNegativeRegexpLineIteratorWrapper generates a new NegativeRegexpLineIteratorWrapper that wraps the given LineIterator and filters on the reverse of the given pattern.
func (NegativeRegexpLineIteratorWrapper) Next ¶
func (i NegativeRegexpLineIteratorWrapper) Next() (Line, error)
Next scrubs through the internal iterator until it finds an entry that matches the pattern.
type PrefixedPathFileInfo ¶
type PrefixedPathFileInfo struct {
// contains filtered or unexported fields
}
PrefixedPathFileInfo is a FileInfo implementation that consumes a FileInfo implementation and a path prefix in order to always return the absolute file path for calls to Name(). All other calls are proxied to the underlying FileInfo implementation.
func (PrefixedPathFileInfo) IsDir ¶
func (f PrefixedPathFileInfo) IsDir() bool
IsDir fetches whether or not the file is a directory.
func (PrefixedPathFileInfo) ModTime ¶
func (f PrefixedPathFileInfo) ModTime() time.Time
ModTime fetches the last modified time.
func (PrefixedPathFileInfo) Mode ¶
func (f PrefixedPathFileInfo) Mode() os.FileMode
Mode fetches the associated FileMode.
func (PrefixedPathFileInfo) Name ¶
func (f PrefixedPathFileInfo) Name() string
Name fetches the prefixed path.
func (PrefixedPathFileInfo) Size ¶
func (f PrefixedPathFileInfo) Size() int64
Size fetches the length in bytes.
func (PrefixedPathFileInfo) String ¶
func (f PrefixedPathFileInfo) String() string
func (PrefixedPathFileInfo) Sys ¶
func (f PrefixedPathFileInfo) Sys() interface{}
Sys fetches the underlying data source.
type RegexpLineIteratorWrapper ¶
type RegexpLineIteratorWrapper struct {
// contains filtered or unexported fields
}
RegexpLineIteratorWrapper filters all lines from the wrapped LineIterator based on a regexp search.
func NewRegexpLineIteratorWrapper ¶
func NewRegexpLineIteratorWrapper(pattern *regexp.Regexp, iterator LineIterator) (*RegexpLineIteratorWrapper, error)
NewRegexpLineIteratorWrapper generates a new RegexpLineIteratorWrapper that wraps the given LineIterator and filters on the given pattern.
func (RegexpLineIteratorWrapper) Next ¶
func (i RegexpLineIteratorWrapper) Next() (Line, error)
Next scrubs through the internal iterator until it finds an entry that matches the pattern.