Documentation ¶
Overview ¶
Package os provides an OS interface mirroring a subset of commonly used functions and variables from the golang os package.
Index ¶
- func ReadIfNonEmpty(f *os.File) (string, error)
- type DirEntryFilter
- type DirReader
- type MockDirReader
- type MockDirReaderMockRecorder
- type MockFileInfo
- type MockFileInfoMockRecorder
- func (mr *MockFileInfoMockRecorder) IsDir() *gomock.Call
- func (mr *MockFileInfoMockRecorder) ModTime() *gomock.Call
- func (mr *MockFileInfoMockRecorder) Mode() *gomock.Call
- func (mr *MockFileInfoMockRecorder) Name() *gomock.Call
- func (mr *MockFileInfoMockRecorder) Size() *gomock.Call
- func (mr *MockFileInfoMockRecorder) Sys() *gomock.Call
- type MockOS
- func (m *MockOS) Args() []string
- func (m *MockOS) Create(name string) (*os0.File, error)
- func (m *MockOS) EXPECT() *MockOSMockRecorder
- func (m *MockOS) Exit(code int)
- func (m *MockOS) ExpandEnv(s string) string
- func (m *MockOS) Getenv(key string) string
- func (m *MockOS) IsNotExist(err error) bool
- func (m *MockOS) LookupEnv(key string) (string, bool)
- func (m *MockOS) MkdirAll(path string, perm os0.FileMode) error
- func (m *MockOS) NewDirReader(dir string) DirReader
- func (m *MockOS) Open(name string) (*os0.File, error)
- func (m *MockOS) OpenFile(name string, flag int, perm os0.FileMode) (*os0.File, error)
- func (m *MockOS) Remove(name string) error
- func (m *MockOS) Rename(oldpath, newpath string) error
- func (m *MockOS) Setenv(key, value string) error
- func (m *MockOS) Stat(name string) (os0.FileInfo, error)
- func (m *MockOS) Stderr() io.Writer
- func (m *MockOS) Stdin() io.Reader
- func (m *MockOS) Stdout() io.Writer
- type MockOSMockRecorder
- func (mr *MockOSMockRecorder) Args() *gomock.Call
- func (mr *MockOSMockRecorder) Create(name interface{}) *gomock.Call
- func (mr *MockOSMockRecorder) Exit(code interface{}) *gomock.Call
- func (mr *MockOSMockRecorder) ExpandEnv(s interface{}) *gomock.Call
- func (mr *MockOSMockRecorder) Getenv(key interface{}) *gomock.Call
- func (mr *MockOSMockRecorder) IsNotExist(err interface{}) *gomock.Call
- func (mr *MockOSMockRecorder) LookupEnv(key interface{}) *gomock.Call
- func (mr *MockOSMockRecorder) MkdirAll(path, perm interface{}) *gomock.Call
- func (mr *MockOSMockRecorder) NewDirReader(dir interface{}) *gomock.Call
- func (mr *MockOSMockRecorder) Open(name interface{}) *gomock.Call
- func (mr *MockOSMockRecorder) OpenFile(name, flag, perm interface{}) *gomock.Call
- func (mr *MockOSMockRecorder) Remove(name interface{}) *gomock.Call
- func (mr *MockOSMockRecorder) Rename(oldpath, newpath interface{}) *gomock.Call
- func (mr *MockOSMockRecorder) Setenv(key, value interface{}) *gomock.Call
- func (mr *MockOSMockRecorder) Stat(name interface{}) *gomock.Call
- func (mr *MockOSMockRecorder) Stderr() *gomock.Call
- func (mr *MockOSMockRecorder) Stdin() *gomock.Call
- func (mr *MockOSMockRecorder) Stdout() *gomock.Call
- type OS
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type DirEntryFilter ¶
DirEntryFilter is a function that filters directory entries by returning true for directories that should be accepted.
type DirReader ¶
type DirReader interface { // Read reads all entries from the directory. Read() ([]string, error) // Filter returns all entries from the directory that match // the given filter. Filter(DirEntryFilter) ([]string, error) }
DirReader reads or reads and filters directory entries.
func NewDirReader ¶
NewDirReader constructs a new DirReader for the given path name.
type MockDirReader ¶
type MockDirReader struct {
// contains filtered or unexported fields
}
MockDirReader is a mock of DirReader interface
func NewMockDirReader ¶
func NewMockDirReader(ctrl *gomock.Controller) *MockDirReader
NewMockDirReader creates a new mock instance
func (*MockDirReader) EXPECT ¶
func (m *MockDirReader) EXPECT() *MockDirReaderMockRecorder
EXPECT returns an object that allows the caller to indicate expected use
func (*MockDirReader) Filter ¶
func (m *MockDirReader) Filter(arg0 DirEntryFilter) ([]string, error)
Filter mocks base method
func (*MockDirReader) Read ¶
func (m *MockDirReader) Read() ([]string, error)
Read mocks base method
type MockDirReaderMockRecorder ¶
type MockDirReaderMockRecorder struct {
// contains filtered or unexported fields
}
MockDirReaderMockRecorder is the mock recorder for MockDirReader
func (*MockDirReaderMockRecorder) Filter ¶
func (mr *MockDirReaderMockRecorder) Filter(arg0 interface{}) *gomock.Call
Filter indicates an expected call of Filter
func (*MockDirReaderMockRecorder) Read ¶
func (mr *MockDirReaderMockRecorder) Read() *gomock.Call
Read indicates an expected call of Read
type MockFileInfo ¶
type MockFileInfo struct {
// contains filtered or unexported fields
}
MockFileInfo is a mock of FileInfo interface
func NewMockFileInfo ¶
func NewMockFileInfo(ctrl *gomock.Controller) *MockFileInfo
NewMockFileInfo creates a new mock instance
func (*MockFileInfo) EXPECT ¶
func (m *MockFileInfo) EXPECT() *MockFileInfoMockRecorder
EXPECT returns an object that allows the caller to indicate expected use
type MockFileInfoMockRecorder ¶
type MockFileInfoMockRecorder struct {
// contains filtered or unexported fields
}
MockFileInfoMockRecorder is the mock recorder for MockFileInfo
func (*MockFileInfoMockRecorder) IsDir ¶
func (mr *MockFileInfoMockRecorder) IsDir() *gomock.Call
IsDir indicates an expected call of IsDir
func (*MockFileInfoMockRecorder) ModTime ¶
func (mr *MockFileInfoMockRecorder) ModTime() *gomock.Call
ModTime indicates an expected call of ModTime
func (*MockFileInfoMockRecorder) Mode ¶
func (mr *MockFileInfoMockRecorder) Mode() *gomock.Call
Mode indicates an expected call of Mode
func (*MockFileInfoMockRecorder) Name ¶
func (mr *MockFileInfoMockRecorder) Name() *gomock.Call
Name indicates an expected call of Name
func (*MockFileInfoMockRecorder) Size ¶
func (mr *MockFileInfoMockRecorder) Size() *gomock.Call
Size indicates an expected call of Size
func (*MockFileInfoMockRecorder) Sys ¶
func (mr *MockFileInfoMockRecorder) Sys() *gomock.Call
Sys indicates an expected call of Sys
type MockOS ¶
type MockOS struct {
// contains filtered or unexported fields
}
MockOS is a mock of OS interface
func NewMockOS ¶
func NewMockOS(ctrl *gomock.Controller) *MockOS
NewMockOS creates a new mock instance
func (*MockOS) EXPECT ¶
func (m *MockOS) EXPECT() *MockOSMockRecorder
EXPECT returns an object that allows the caller to indicate expected use
func (*MockOS) IsNotExist ¶
IsNotExist mocks base method
func (*MockOS) NewDirReader ¶
NewDirReader mocks base method
type MockOSMockRecorder ¶
type MockOSMockRecorder struct {
// contains filtered or unexported fields
}
MockOSMockRecorder is the mock recorder for MockOS
func (*MockOSMockRecorder) Args ¶
func (mr *MockOSMockRecorder) Args() *gomock.Call
Args indicates an expected call of Args
func (*MockOSMockRecorder) Create ¶
func (mr *MockOSMockRecorder) Create(name interface{}) *gomock.Call
Create indicates an expected call of Create
func (*MockOSMockRecorder) Exit ¶
func (mr *MockOSMockRecorder) Exit(code interface{}) *gomock.Call
Exit indicates an expected call of Exit
func (*MockOSMockRecorder) ExpandEnv ¶
func (mr *MockOSMockRecorder) ExpandEnv(s interface{}) *gomock.Call
ExpandEnv indicates an expected call of ExpandEnv
func (*MockOSMockRecorder) Getenv ¶
func (mr *MockOSMockRecorder) Getenv(key interface{}) *gomock.Call
Getenv indicates an expected call of Getenv
func (*MockOSMockRecorder) IsNotExist ¶
func (mr *MockOSMockRecorder) IsNotExist(err interface{}) *gomock.Call
IsNotExist indicates an expected call of IsNotExist
func (*MockOSMockRecorder) LookupEnv ¶
func (mr *MockOSMockRecorder) LookupEnv(key interface{}) *gomock.Call
LookupEnv indicates an expected call of LookupEnv
func (*MockOSMockRecorder) MkdirAll ¶
func (mr *MockOSMockRecorder) MkdirAll(path, perm interface{}) *gomock.Call
MkdirAll indicates an expected call of MkdirAll
func (*MockOSMockRecorder) NewDirReader ¶
func (mr *MockOSMockRecorder) NewDirReader(dir interface{}) *gomock.Call
NewDirReader indicates an expected call of NewDirReader
func (*MockOSMockRecorder) Open ¶
func (mr *MockOSMockRecorder) Open(name interface{}) *gomock.Call
Open indicates an expected call of Open
func (*MockOSMockRecorder) OpenFile ¶
func (mr *MockOSMockRecorder) OpenFile(name, flag, perm interface{}) *gomock.Call
OpenFile indicates an expected call of OpenFile
func (*MockOSMockRecorder) Remove ¶
func (mr *MockOSMockRecorder) Remove(name interface{}) *gomock.Call
Remove indicates an expected call of Remove
func (*MockOSMockRecorder) Rename ¶
func (mr *MockOSMockRecorder) Rename(oldpath, newpath interface{}) *gomock.Call
Rename indicates an expected call of Rename
func (*MockOSMockRecorder) Setenv ¶
func (mr *MockOSMockRecorder) Setenv(key, value interface{}) *gomock.Call
Setenv indicates an expected call of Setenv
func (*MockOSMockRecorder) Stat ¶
func (mr *MockOSMockRecorder) Stat(name interface{}) *gomock.Call
Stat indicates an expected call of Stat
func (*MockOSMockRecorder) Stderr ¶
func (mr *MockOSMockRecorder) Stderr() *gomock.Call
Stderr indicates an expected call of Stderr
func (*MockOSMockRecorder) Stdin ¶
func (mr *MockOSMockRecorder) Stdin() *gomock.Call
Stdin indicates an expected call of Stdin
func (*MockOSMockRecorder) Stdout ¶
func (mr *MockOSMockRecorder) Stdout() *gomock.Call
Stdout indicates an expected call of Stdout
type OS ¶
type OS interface { Args() []string Create(name string) (*os.File, error) Getenv(key string) string LookupEnv(key string) (value string, found bool) ExpandEnv(s string) string Setenv(key, value string) error Exit(code int) Stdin() io.Reader Stdout() io.Writer Stderr() io.Writer Stat(name string) (os.FileInfo, error) IsNotExist(err error) bool Remove(name string) error Rename(oldpath, newpath string) error Open(name string) (*os.File, error) OpenFile(name string, flag int, perm os.FileMode) (*os.File, error) MkdirAll(path string, perm os.FileMode) error // Constructs a new DirReader via NewDirReader. NewDirReader(dir string) DirReader }
OS is an interface on top of commonly used functions and variables from the golang os package, for easier testing. New methods can be added as needed.
For undocumented functions, see correspondingly named things at https://golang.org/pkg/os.