Documentation ¶
Index ¶
- Variables
- func GetPath(root string) string
- func GetPaths(root string) []string
- type Locator
- func First(locators ...Locator) Locator
- func NewCharDeviceLocator(opts ...Option) Locator
- func NewDirectoryLocator(opts ...Option) Locator
- func NewExecutableLocator(logger logger.Interface, root string) Locator
- func NewFileLocator(opts ...Option) Locator
- func NewLibraryLocator(opts ...Option) Locator
- func NewSymlinkChainLocator(opts ...Option) Locator
- func NewSymlinkLocator(opts ...Option) Locator
- type LocatorMock
- type Option
Constants ¶
This section is empty.
Variables ¶
var ErrNotFound = errors.New("not found")
ErrNotFound indicates that a specified pattern or file could not be found.
Functions ¶
Types ¶
type Locator ¶
Locator defines the interface for locating files on a system.
func NewCharDeviceLocator ¶
NewCharDeviceLocator creates a Locator that can be used to find char devices at the specified root. A logger is also specified.
func NewDirectoryLocator ¶
NewDirectoryLocator creates a Locator that can be used to find directories at the specified root.
func NewExecutableLocator ¶
NewExecutableLocator creates a locator to fine executable files in the path. A logger can also be specified.
func NewFileLocator ¶
NewFileLocator creates a Locator that can be used to find files with the specified builder.
func NewLibraryLocator ¶ added in v1.12.0
NewLibraryLocator creates a library locator using the specified options.
func NewSymlinkChainLocator ¶
NewSymlinkChainLocator creats a locator that can be used for locating files through symlinks.
func NewSymlinkLocator ¶
NewSymlinkLocator creats a locator that can be used for locating files through symlinks.
type LocatorMock ¶
type LocatorMock struct { // LocateFunc mocks the Locate method. LocateFunc func(s string) ([]string, error) // contains filtered or unexported fields }
LocatorMock is a mock implementation of Locator.
func TestSomethingThatUsesLocator(t *testing.T) { // make and configure a mocked Locator mockedLocator := &LocatorMock{ LocateFunc: func(s string) ([]string, error) { panic("mock out the Locate method") }, } // use mockedLocator in code that requires Locator // and then make assertions. }
func (*LocatorMock) Locate ¶
func (mock *LocatorMock) Locate(s string) ([]string, error)
Locate calls LocateFunc.
func (*LocatorMock) LocateCalls ¶
func (mock *LocatorMock) LocateCalls() []struct { S string }
LocateCalls gets all the calls that were made to Locate. Check the length with:
len(mockedLocator.LocateCalls())
type Option ¶ added in v1.12.0
type Option func(*builder)
Option defines a function for passing builder to the NewFileLocator() call
func WithFilter ¶ added in v1.12.0
WithFilter sets the filter for the file locator The filter is called for each candidate file and candidates that return nil are considered.
func WithLogger ¶ added in v1.12.0
WithLogger sets the logger for the file locator
func WithOptional ¶ added in v1.12.0
WithOptional sets the optional flag for the file locator If the optional flag is set, the locator will not return an error if the file is not found.
func WithSearchPaths ¶ added in v1.12.0
WithSearchPaths sets the search paths for the file locator.