sys

package
v2.0.0-beta4+incompatible Latest Latest
Warning

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

Go to latest
Published: May 11, 2016 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Env

type Env interface {
	// Get gets the environment variable of the given name.
	Get(name string) string
}

Env is an interface to a set of environment variables.

func RealEnv

func RealEnv() Env

RealEnv returns an Env implementation that uses os.Getenv every time Get is called.

type FS

type FS interface {
	// ReadAll gets the contents of filename, or an error if the file didn't exist or there was an
	// error reading it.
	ReadFile(filename string) ([]byte, error)

	// RemoveAll removes all of the files under the directory at name. It behaves similarly to the
	// func of the same name in the os package (https://godoc.org/os#RemoveAll).
	RemoveAll(name string) error
}

FS is the interface to a file system.

func RealFS

func RealFS() FS

RealFS returns an FS object that interacts with the real local filesystem.

type FakeEnv

type FakeEnv struct {
	// Envs is the map from which Get calls will look to retrieve environment variables.
	Envs map[string]string
}

FakeEnv is an Env implementation that stores the environment in a map.

func NewFakeEnv

func NewFakeEnv() *FakeEnv

NewFakeEnv returns a new FakeEnv with no values in Envs.

func (*FakeEnv) Get

func (f *FakeEnv) Get(name string) string

Get is the Env interface implementation for Env.

type FakeFS

type FakeFS struct {
	Files map[string][]byte
}

FakeFS is an in-memory FS implementation.

func NewFakeFS

func NewFakeFS() *FakeFS

NewFakeFS returns a FakeFS with no files.

func (*FakeFS) ReadFile

func (f *FakeFS) ReadFile(name string) ([]byte, error)

ReadFile is the FS interface implementation. It returns FakeFileNotFound if the file was not found in the in-memory 'filesystem' of f.

func (*FakeFS) RemoveAll

func (f *FakeFS) RemoveAll(name string) error

RemoveAll is the interface implementation for FS.

type FakeFileNotFound

type FakeFileNotFound struct {
	Filename string
}

FakeFileNotFound is the error returned by FakeFS when a requested file isn't found.

func (FakeFileNotFound) Error

func (f FakeFileNotFound) Error() string

Error is the error interface implementation.

Jump to

Keyboard shortcuts

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