system

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 17, 2022 License: Apache-2.0 Imports: 3 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EnvGetter

type EnvGetter interface {
	Env(key string) string
}

EnvGetter mocks out os.Getenv.

type EnvironGetter

type EnvironGetter interface {
	Environ() []string
}

EnvironGetter mocks out os.Environ.

type ExecutableFinder

type ExecutableFinder interface {
	Executable() (string, error)
}

ExecutableFinder mocks out os.Executable.

type FilePathJoiner

type FilePathJoiner interface {
	FilePathJoin(elem ...string) string
}

FilePathJoiner mocks out filepath.Join.

type RuntimeCPUGetter

type RuntimeCPUGetter interface {
	NumCPU() int
}

RuntimeCPUGetter mocks out runtime.NumCPU.

type StdLib

type StdLib struct{}

StdLib implements the interfaces defined in system.go via standard library functions.

func NewStdLib

func NewStdLib() *StdLib

func (*StdLib) Env

func (s *StdLib) Env(key string) string

func (*StdLib) Environ

func (s *StdLib) Environ() []string
func (s *StdLib) EvalSymlinks(path string) (string, error)

func (*StdLib) Executable

func (s *StdLib) Executable() (string, error)

func (*StdLib) FilePathJoin

func (s *StdLib) FilePathJoin(elem ...string) string

func (*StdLib) NumCPU

func (s *StdLib) NumCPU() int

func (*StdLib) ReadMemStats

func (s *StdLib) ReadMemStats(st *runtime.MemStats)

func (*StdLib) Stderr

func (s *StdLib) Stderr() *os.File

func (*StdLib) Stdin

func (s *StdLib) Stdin() *os.File

func (*StdLib) Stdout

func (s *StdLib) Stdout() *os.File

type StderrGetter

type StderrGetter interface {
	Stderr() *os.File
}

StderrGetter mocks out os.Stderr.

type StdinGetter

type StdinGetter interface {
	Stdin() *os.File
}

StdinGetter mocks out os.Stdin.

type StdoutGetter

type StdoutGetter interface {
	Stdout() *os.File
}

StdoutGetter mocks out os.Stdout.

type SymlinksEvaluator

type SymlinksEvaluator interface {
	EvalSymlinks(path string) (string, error)
}

SymlinksEvaluator mocks out filepath.EvalSymlinks.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL