filesystem

package
v0.169.0 Latest Latest
Warning

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

Go to latest
Published: May 31, 2022 License: MIT Imports: 6 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Inject added in v0.107.0

func Inject(ctx context.Context, fs Service) context.Context

Inject will inject this filesystem Service into the context.

func ReadFile

func ReadFile(ctx context.Context, filename string) ([]byte, error)

ReadFile will open the file from the service and read the entire contents.

func Stat added in v0.107.0

func Stat(ctx context.Context, filename string) (os.FileInfo, error)

Stat will retrieve the os.FileInfo for a file.

Types

type Dependency added in v0.107.0

type Dependency struct {
	FS Service
}

Dependency will inject the filesystem Service into the dependency chain.

func (Dependency) Inject added in v0.107.0

func (d Dependency) Inject(ctx context.Context) context.Context

Inject will inject the filesystem Service into the dependency chain.

type File

type File interface {
	io.ReadCloser
	Stat() (os.FileInfo, error)
}

File is an interface for interacting with a file.

func OpenFile added in v0.107.0

func OpenFile(ctx context.Context, filename string) (File, error)

OpenFile will open the file from the service.

type Service

type Service interface {
	Open(fpath string) (File, error)
}

Service is the service for accessing the filesystem.

var SystemFS Service = systemFS{}

SystemFS implements the filesystem.Service by proxying all requests to the filesystem.

func Get added in v0.107.0

func Get(ctx context.Context) (Service, error)

Get will retrieve a filesystem Service from the context.Context.

Jump to

Keyboard shortcuts

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