fs

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2021 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package fs provides an interface over file system interactions. This allows for easy mocking in tests.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type File

type File interface {
	io.Closer
	io.Reader
	io.ReaderAt
	io.Seeker
	io.Writer
	io.WriterAt
	Stat() (os.FileInfo, error)
}

File provides a mockable interface for os file operations

type FileInfo

type FileInfo interface {
	Name() string       // base name of the file
	Size() int64        // length in bytes for regular files; system-dependent for others
	Mode() os.FileMode  // file mode bits
	ModTime() time.Time // modification time
	IsDir() bool        // abbreviation for Mode().IsDir()
	Sys() interface{}   // underlying data source (can return nil)
}

FileInfo provides a mockable interface for file operations

type FileMode

type FileMode os.FileMode

FileMode is a type alias for os.FileMode

type FileSystem

type FileSystem interface {
	NewFile(fd uintptr, name string) File
	Create(name string) (File, error)
	Open(name string) (File, error)
	Stat(name string) (FileInfo, error)
	RemoveAll(name string) error
	MkdirAll(name string, mode FileMode) error
	ReadFile(filename string) ([]byte, error)
	WriteFile(filename string, data []byte, mode FileMode) error
}

FileSystem provides a mockable abstraction over os file methods

func NewLocalFS

func NewLocalFS() FileSystem

NewLocalFS creates a FileSystem interface that interacts with the local file system

Jump to

Keyboard shortcuts

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