Documentation ¶
Overview ¶
Package walker provides implementations for walking over files in a filesystem.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FSReverseWalker ¶
type FSReverseWalker struct {
// contains filtered or unexported fields
}
FSReverseWalker is a ReverseWalker that walks over the local filesystem.
func NewCustomReverseFSWalker ¶
func NewCustomReverseFSWalker(fs afero.Fs, logger *slog.Logger) FSReverseWalker
NewCustomReverseFSWalker creates a new FSReverseWalker with the given filesystem and an optional logger.
func NewDefaultFSReverseWalker ¶
func NewDefaultFSReverseWalker(logger *slog.Logger) FSReverseWalker
NewFSReverseWalker creates a new FSReverseWalker with default settings and an optional logger.
func NewFSReverseWalker ¶
func NewFSReverseWalker(logger *slog.Logger, fs afero.Fs) FSReverseWalker
NewFSReverseWalker creates a new FSReverseWalker with an optional logger.
func (*FSReverseWalker) Walk ¶
func (w *FSReverseWalker) Walk(startPath, endPath string, callback WalkerCallback) error
Walk performs a reverse walk over the files and directories from the start path to the end path and calls the given function for each entry.
type FSWalker ¶
type FSWalker struct {
// contains filtered or unexported fields
}
FilesystemWalker is a walker that walks over the local filesystem.
func NewCustomDefaultFSWalker ¶
NewCustomDefaultFilesystemWalker creates a new FSWalker with the given filesystem and an optional logger.
func NewDefaultFSWalker ¶
NewDefaultFilesystemWalker creates a new FSWalker with the default filesystem and an optional logger.
func NewFSWalker ¶
NewFilesystemWalker creates a new FSWalker with the given filesystem.
type FileSeeker ¶
FileSeeker is an interface that combines the fs.File and io.Seeker interfaces.
type ReverseWalker ¶
type ReverseWalker interface { // Walk performs a reverse walk from the end path to the start path and // calls the given function for each file. Walk(startPath, endPath string, callback WalkerCallback) error }
ReverseWalker is an interface that allows reverse walking over a set of files. The start path is the path where the walk starts and the end path is the path where the walk ends.
type ReverseWalkerMock ¶
type ReverseWalkerMock struct { // WalkFunc mocks the Walk method. WalkFunc func(startPath string, endPath string, callback WalkerCallback) error // contains filtered or unexported fields }
ReverseWalkerMock is a mock implementation of ReverseWalker.
func TestSomethingThatUsesReverseWalker(t *testing.T) { // make and configure a mocked ReverseWalker mockedReverseWalker := &ReverseWalkerMock{ WalkFunc: func(startPath string, endPath string, callback WalkerCallback) error { panic("mock out the Walk method") }, } // use mockedReverseWalker in code that requires ReverseWalker // and then make assertions. }
func (*ReverseWalkerMock) Walk ¶
func (mock *ReverseWalkerMock) Walk(startPath string, endPath string, callback WalkerCallback) error
Walk calls WalkFunc.
func (*ReverseWalkerMock) WalkCalls ¶
func (mock *ReverseWalkerMock) WalkCalls() []struct { StartPath string EndPath string Callback WalkerCallback }
WalkCalls gets all the calls that were made to Walk. Check the length with:
len(mockedReverseWalker.WalkCalls())
type Walker ¶
type Walker interface { // Walk walks over the files in the given root path and calls the given // function for each file. Walk(rootPath string, callback WalkerCallback) error }
Walker is an interface that allows walking over a set of files.
type WalkerCallback ¶
type WalkerCallback func(string, FileType, func() (FileSeeker, error)) error
WalkerCallback is a callback function that is called for each file in the Walk function.