Documentation
¶
Overview ¶
Package fs provides file system operations and error definitions.
Package fs is a generated GoMock package.
Index ¶
- Variables
- type FS
- type MockFS
- func (m *MockFS) CreateDirectory(path string, perm os.FileMode) error
- func (m *MockFS) CreateFileIfNotExists(filename string, initialContent []byte, perm os.FileMode) error
- func (m *MockFS) CreateFileWithContent(path string, content []byte, perm os.FileMode) error
- func (m *MockFS) EXPECT() *MockFSMockRecorder
- func (m *MockFS) ExecuteCommand(command string, args ...string) error
- func (m *MockFS) Exists(path string) (bool, error)
- func (m *MockFS) ExpandPath(path string) (string, error)
- func (m *MockFS) FileLock(filename string) (func(), error)
- func (m *MockFS) GetHomeDir() (string, error)
- func (m *MockFS) Glob(pattern string) ([]string, error)
- func (m *MockFS) IsDir(path string) (bool, error)
- func (m *MockFS) IsDirectoryWritable(path string) (bool, error)
- func (m *MockFS) IsNotExist(err error) bool
- func (m *MockFS) MkdirAll(path string, perm os.FileMode) error
- func (m *MockFS) ReadDir(path string) ([]os.DirEntry, error)
- func (m *MockFS) ReadFile(path string) ([]byte, error)
- func (m *MockFS) RemoveAll(path string) error
- func (m *MockFS) Which(command string) (string, error)
- func (m *MockFS) WriteFileAtomic(filename string, data []byte, perm os.FileMode) error
- type MockFSMockRecorder
- func (mr *MockFSMockRecorder) CreateDirectory(path, perm any) *gomock.Call
- func (mr *MockFSMockRecorder) CreateFileIfNotExists(filename, initialContent, perm any) *gomock.Call
- func (mr *MockFSMockRecorder) CreateFileWithContent(path, content, perm any) *gomock.Call
- func (mr *MockFSMockRecorder) ExecuteCommand(command any, args ...any) *gomock.Call
- func (mr *MockFSMockRecorder) Exists(path any) *gomock.Call
- func (mr *MockFSMockRecorder) ExpandPath(path any) *gomock.Call
- func (mr *MockFSMockRecorder) FileLock(filename any) *gomock.Call
- func (mr *MockFSMockRecorder) GetHomeDir() *gomock.Call
- func (mr *MockFSMockRecorder) Glob(pattern any) *gomock.Call
- func (mr *MockFSMockRecorder) IsDir(path any) *gomock.Call
- func (mr *MockFSMockRecorder) IsDirectoryWritable(path any) *gomock.Call
- func (mr *MockFSMockRecorder) IsNotExist(err any) *gomock.Call
- func (mr *MockFSMockRecorder) MkdirAll(path, perm any) *gomock.Call
- func (mr *MockFSMockRecorder) ReadDir(path any) *gomock.Call
- func (mr *MockFSMockRecorder) ReadFile(path any) *gomock.Call
- func (mr *MockFSMockRecorder) RemoveAll(path any) *gomock.Call
- func (mr *MockFSMockRecorder) Which(command any) *gomock.Call
- func (mr *MockFSMockRecorder) WriteFileAtomic(filename, data, perm any) *gomock.Call
Constants ¶
This section is empty.
Variables ¶
var ( // File lock errors. ErrFileLock = errors.New("lock") )
Error definitions for fs package.
Functions ¶
This section is empty.
Types ¶
type FS ¶
type FS interface { // Exists checks if a file or directory exists at the given path. Exists(path string) (bool, error) // IsDir checks if the path is a directory. IsDir(path string) (bool, error) // ReadFile reads the contents of a file. ReadFile(path string) ([]byte, error) // ReadDir reads the contents of a directory. ReadDir(path string) ([]os.DirEntry, error) // Glob finds files matching the pattern. Glob(pattern string) ([]string, error) // MkdirAll creates a directory and all parent directories. MkdirAll(path string, perm os.FileMode) error // GetHomeDir returns the user's home directory path. GetHomeDir() (string, error) // IsNotExist checks if an error indicates that a file or directory doesn't exist. IsNotExist(err error) bool // WriteFileAtomic writes data to a file atomically using a temporary file and rename. WriteFileAtomic(filename string, data []byte, perm os.FileMode) error // FileLock acquires a file lock and returns an unlock function. FileLock(filename string) (func(), error) // CreateFileIfNotExists creates a file with initial content if it doesn't exist. CreateFileIfNotExists(filename string, initialContent []byte, perm os.FileMode) error // RemoveAll removes a file or directory and all its contents. RemoveAll(path string) error // Which finds the executable path for a command using the system's PATH. Which(command string) (string, error) // ExecuteCommand executes a command with arguments in the background. ExecuteCommand(command string, args ...string) error // CreateDirectory creates a directory with permissions. CreateDirectory(path string, perm os.FileMode) error // CreateFileWithContent creates a file with content. CreateFileWithContent(path string, content []byte, perm os.FileMode) error // IsDirectoryWritable checks if a directory is writable. IsDirectoryWritable(path string) (bool, error) // ExpandPath expands ~ to user's home directory. ExpandPath(path string) (string, error) }
FS interface provides file system operations for Git repository detection.
type MockFS ¶
type MockFS struct {
// contains filtered or unexported fields
}
MockFS is a mock of FS interface.
func NewMockFS ¶
func NewMockFS(ctrl *gomock.Controller) *MockFS
NewMockFS creates a new mock instance.
func (*MockFS) CreateDirectory ¶
CreateDirectory mocks base method.
func (*MockFS) CreateFileIfNotExists ¶
func (m *MockFS) CreateFileIfNotExists(filename string, initialContent []byte, perm os.FileMode) error
CreateFileIfNotExists mocks base method.
func (*MockFS) CreateFileWithContent ¶
CreateFileWithContent mocks base method.
func (*MockFS) EXPECT ¶
func (m *MockFS) EXPECT() *MockFSMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockFS) ExecuteCommand ¶
ExecuteCommand mocks base method.
func (*MockFS) ExpandPath ¶
ExpandPath mocks base method.
func (*MockFS) GetHomeDir ¶
GetHomeDir mocks base method.
func (*MockFS) IsDirectoryWritable ¶
IsDirectoryWritable mocks base method.
func (*MockFS) IsNotExist ¶
IsNotExist mocks base method.
type MockFSMockRecorder ¶
type MockFSMockRecorder struct {
// contains filtered or unexported fields
}
MockFSMockRecorder is the mock recorder for MockFS.
func (*MockFSMockRecorder) CreateDirectory ¶
func (mr *MockFSMockRecorder) CreateDirectory(path, perm any) *gomock.Call
CreateDirectory indicates an expected call of CreateDirectory.
func (*MockFSMockRecorder) CreateFileIfNotExists ¶
func (mr *MockFSMockRecorder) CreateFileIfNotExists(filename, initialContent, perm any) *gomock.Call
CreateFileIfNotExists indicates an expected call of CreateFileIfNotExists.
func (*MockFSMockRecorder) CreateFileWithContent ¶
func (mr *MockFSMockRecorder) CreateFileWithContent(path, content, perm any) *gomock.Call
CreateFileWithContent indicates an expected call of CreateFileWithContent.
func (*MockFSMockRecorder) ExecuteCommand ¶
func (mr *MockFSMockRecorder) ExecuteCommand(command any, args ...any) *gomock.Call
ExecuteCommand indicates an expected call of ExecuteCommand.
func (*MockFSMockRecorder) Exists ¶
func (mr *MockFSMockRecorder) Exists(path any) *gomock.Call
Exists indicates an expected call of Exists.
func (*MockFSMockRecorder) ExpandPath ¶
func (mr *MockFSMockRecorder) ExpandPath(path any) *gomock.Call
ExpandPath indicates an expected call of ExpandPath.
func (*MockFSMockRecorder) FileLock ¶
func (mr *MockFSMockRecorder) FileLock(filename any) *gomock.Call
FileLock indicates an expected call of FileLock.
func (*MockFSMockRecorder) GetHomeDir ¶
func (mr *MockFSMockRecorder) GetHomeDir() *gomock.Call
GetHomeDir indicates an expected call of GetHomeDir.
func (*MockFSMockRecorder) Glob ¶
func (mr *MockFSMockRecorder) Glob(pattern any) *gomock.Call
Glob indicates an expected call of Glob.
func (*MockFSMockRecorder) IsDir ¶
func (mr *MockFSMockRecorder) IsDir(path any) *gomock.Call
IsDir indicates an expected call of IsDir.
func (*MockFSMockRecorder) IsDirectoryWritable ¶
func (mr *MockFSMockRecorder) IsDirectoryWritable(path any) *gomock.Call
IsDirectoryWritable indicates an expected call of IsDirectoryWritable.
func (*MockFSMockRecorder) IsNotExist ¶
func (mr *MockFSMockRecorder) IsNotExist(err any) *gomock.Call
IsNotExist indicates an expected call of IsNotExist.
func (*MockFSMockRecorder) MkdirAll ¶
func (mr *MockFSMockRecorder) MkdirAll(path, perm any) *gomock.Call
MkdirAll indicates an expected call of MkdirAll.
func (*MockFSMockRecorder) ReadDir ¶
func (mr *MockFSMockRecorder) ReadDir(path any) *gomock.Call
ReadDir indicates an expected call of ReadDir.
func (*MockFSMockRecorder) ReadFile ¶
func (mr *MockFSMockRecorder) ReadFile(path any) *gomock.Call
ReadFile indicates an expected call of ReadFile.
func (*MockFSMockRecorder) RemoveAll ¶
func (mr *MockFSMockRecorder) RemoveAll(path any) *gomock.Call
RemoveAll indicates an expected call of RemoveAll.
func (*MockFSMockRecorder) Which ¶
func (mr *MockFSMockRecorder) Which(command any) *gomock.Call
Which indicates an expected call of Which.
func (*MockFSMockRecorder) WriteFileAtomic ¶
func (mr *MockFSMockRecorder) WriteFileAtomic(filename, data, perm any) *gomock.Call
WriteFileAtomic indicates an expected call of WriteFileAtomic.