filesystem

package
v0.1.0-latest-stable Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2026 License: Apache-2.0 Imports: 2 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultFileSystem = OSFileSystem{}
)

Functions

func AtomicWrite

func AtomicWrite(name string, data []byte, perm os.FileMode) error

func MkdirAll

func MkdirAll(path string, perm os.FileMode) error

func Open

func Open(name string) (*os.File, error)

func ReadDir

func ReadDir(name string) ([]os.DirEntry, error)

func ReadFile

func ReadFile(name string) ([]byte, error)

func Remove

func Remove(name string) error

func Stat

func Stat(name string) (os.FileInfo, error)

func WriteFile

func WriteFile(name string, data []byte, perm os.FileMode) error

Types

type FileSystem

type FileSystem interface {
	Stat(name string) (os.FileInfo, error)
	ReadFile(name string) ([]byte, error)
	WriteFile(name string, data []byte, perm os.FileMode) error
	AtomicWrite(name string, data []byte, perm os.FileMode) error
	Open(name string) (*os.File, error)
	MkdirAll(path string, perm os.FileMode) error
	ReadDir(name string) ([]os.DirEntry, error)
	Remove(name string) error
}

FileSystem abstracts file and OS operations for testability.

type OSFileSystem

type OSFileSystem struct{}

OSFileSystem is the default implementation of FileSystem using the os package.

func (OSFileSystem) AtomicWrite

func (OSFileSystem) AtomicWrite(name string, data []byte, perm os.FileMode) error

func (OSFileSystem) MkdirAll

func (OSFileSystem) MkdirAll(path string, perm os.FileMode) error

func (OSFileSystem) Open

func (OSFileSystem) Open(name string) (*os.File, error)

func (OSFileSystem) ReadDir

func (OSFileSystem) ReadDir(name string) ([]os.DirEntry, error)

func (OSFileSystem) ReadFile

func (OSFileSystem) ReadFile(name string) ([]byte, error)

func (OSFileSystem) Remove

func (OSFileSystem) Remove(name string) error

func (OSFileSystem) Stat

func (OSFileSystem) Stat(name string) (os.FileInfo, error)

func (OSFileSystem) WriteFile

func (OSFileSystem) WriteFile(name string, data []byte, perm os.FileMode) error

Jump to

Keyboard shortcuts

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