Documentation
¶
Overview ¶
Package filesystem is used for providing OS level file utility methods.
Index ¶
- type FileSystem
- type Helper
- func (h Helper) Chmod(path string, perm os.FileMode) error
- func (h Helper) Copy(w io.Writer, r io.Reader) (int64, error)
- func (h Helper) Create(path string) (*os.File, error)
- func (h Helper) MkdirAll(path string, perm os.FileMode) error
- func (h Helper) Open(path string) (*os.File, error)
- func (h Helper) OpenFile(path string, flag int, perm os.FileMode) (*os.File, error)
- func (h Helper) ReadDir(path string) ([]fs.FileInfo, error)
- func (h Helper) ReadFile(path string) ([]byte, error)
- func (h Helper) RemoveAll(path string) error
- func (h Helper) Rename(old, new string) error
- func (h Helper) Seek(file *os.File, offset int64, whence int) (int64, error)
- func (h Helper) Stat(path string) (os.FileInfo, error)
- func (h Helper) WalkAndZip(source string, z zipper.Zipper, w *zip.Writer) error
- func (h Helper) WriteStringToFile(file *os.File, content string) (int, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FileSystem ¶
type FileSystem interface { MkdirAll(string, os.FileMode) error ReadFile(string) ([]byte, error) ReadDir(string) ([]fs.FileInfo, error) Open(string) (*os.File, error) OpenFile(string, int, os.FileMode) (*os.File, error) RemoveAll(string) error Create(string) (*os.File, error) WriteStringToFile(*os.File, string) (int, error) Rename(string, string) error Copy(io.Writer, io.Reader) (int64, error) Chmod(string, os.FileMode) error Stat(string) (os.FileInfo, error) WalkAndZip(string, zipper.Zipper, *zip.Writer) error Seek(*os.File, int64, int) (int64, error) }
FileSystem interface is an interface created to help make OS file system methods testable. Any caller should be able to provide their own mocked implementation in the unit tests.
type Helper ¶
type Helper struct{}
Helper provides a real implementation of the FileSystem interface
func (Helper) WalkAndZip ¶
WalkAndZip provides testable implementation of filepath.Walk which zips the content of the directory.
Click to show internal directories.
Click to hide internal directories.