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 EnvChecker
- type EnvGetter
- type EnvironGetter
- type ExecutableFinder
- type FilePathJoiner
- 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) FilePathJoin(elem ...string) string
- func (s *StdLib) LookupEnv(key string) (string, bool)
- func (s *StdLib) NumCPU() int
- func (s *StdLib) OS() string
- func (s *StdLib) ReadMemStats(st *runtime.MemStats)
- 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 SymlinksEvaluator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
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 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) FilePathJoin ¶
func (*StdLib) ReadMemStats ¶
type StderrGetter ¶
StderrGetter mocks out os.Stderr.
type StdoutGetter ¶
StdoutGetter mocks out os.Stdout.
type SymlinksEvaluator ¶
SymlinksEvaluator mocks out filepath.EvalSymlinks.