Documentation ¶
Overview ¶
Package system contains interfaces for OS related APIs, intended to be used for dependency injection to facilitate unit testing.
The naming of the methods in this package is not very Go-idiomatic because the user of this package usually composes the interfaces in this package into one interface.
For example, the `Executable` method of `ExecutableFinder` should have been named as `Find` according to Go idiom, but it will be unreadable if the interface is embedded in another interface. For instance,
type SystemDeps interface { system.ExecutableFinder // other methods } var deps SystemDeps deps.Executable() // in favor of deps.Find()
Index ¶
- type AbsFilePath
- type EnvChecker
- type EnvGetter
- type EnvironGetter
- type ExecutableFinder
- type FilePathJoiner
- type FilePathToSlash
- type PipeGetter
- type RuntimeArchGetter
- type RuntimeCPUGetter
- type RuntimeOSGetter
- type StdLib
- func (s *StdLib) Arch() string
- func (s *StdLib) Env(key string) string
- func (s *StdLib) Environ() []string
- func (s *StdLib) EvalSymlinks(path string) (string, error)
- func (s *StdLib) Executable() (string, error)
- func (s *StdLib) FilePathAbs(elem string) (string, error)
- func (s *StdLib) FilePathJoin(elem ...string) string
- func (s *StdLib) FilePathToSlash(elem string) string
- func (s *StdLib) GetUserHome() (string, error)
- func (s *StdLib) GetWd() (string, error)
- func (s *StdLib) LookupEnv(key string) (string, bool)
- func (s *StdLib) NumCPU() int
- func (s *StdLib) OS() string
- func (s *StdLib) Pipe() (*os.File, *os.File, error)
- func (s *StdLib) ReadMemStats(st *runtime.MemStats)
- func (s *StdLib) SetStdout(w *os.File)
- func (s *StdLib) Stderr() *os.File
- func (s *StdLib) Stdin() *os.File
- func (s *StdLib) Stdout() *os.File
- type StderrGetter
- type StdinGetter
- type StdoutGetter
- type StdoutSetter
- type SymlinksEvaluator
- type UserHomeDir
- type WorkingDirectory
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AbsFilePath ¶ added in v1.1.0
AbsFilePath mocks out filepath.Abs.
type EnvChecker ¶ added in v0.4.0
EnvChecker mocks out os.LookupEnv.
type EnvironGetter ¶
type EnvironGetter interface {
Environ() []string
}
EnvironGetter mocks out os.Environ.
type ExecutableFinder ¶
ExecutableFinder mocks out os.Executable.
type FilePathJoiner ¶
FilePathJoiner mocks out filepath.Join.
type FilePathToSlash ¶ added in v1.1.0
FilePathToSlash mocks out filepath.ToSlash.
type PipeGetter ¶ added in v1.0.0
PipeGetter mocks out os.Pipe.
type RuntimeArchGetter ¶ added in v0.5.0
type RuntimeArchGetter interface {
Arch() string
}
RuntimeArchGetter mocks out runtime.GOARCH.
type RuntimeCPUGetter ¶
type RuntimeCPUGetter interface {
NumCPU() int
}
RuntimeCPUGetter mocks out runtime.NumCPU.
type RuntimeOSGetter ¶ added in v0.5.0
type RuntimeOSGetter interface {
OS() string
}
RuntimeOSGetter mocks out runtime.GOOS.
type StdLib ¶
type StdLib struct{}
StdLib implements the interfaces defined in system.go via standard library functions.
func (*StdLib) Executable ¶
func (*StdLib) FilePathAbs ¶ added in v1.1.0
func (*StdLib) FilePathJoin ¶
func (*StdLib) FilePathToSlash ¶ added in v1.1.0
func (*StdLib) GetUserHome ¶ added in v1.1.0
func (*StdLib) ReadMemStats ¶
type StderrGetter ¶
StderrGetter mocks out os.Stderr.
type StdoutGetter ¶
StdoutGetter mocks out os.Stdout.
type StdoutSetter ¶ added in v1.0.0
StdoutSetter mocks out redirecting os.Stdout.
type SymlinksEvaluator ¶
SymlinksEvaluator mocks out filepath.EvalSymlinks.
type UserHomeDir ¶ added in v1.1.0
UserHomeDir mocks out os.UserHomeDir.
type WorkingDirectory ¶ added in v1.1.0
WorkingDirectory mocks out os.GetWd.