fs

package
v0.0.0-...-b49207b Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

fs provides most of the functionality that the io/fs package provides and serves as a stand-in replacement. It also allows to mock out the file system in tests.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Create

func Create(name string) (afero.File, error)

Create creates a file in the filesystem, returning the file and an error, if any happens.

func MkdirAll

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

MkdirAll creates a directory path and all parents that does not exist yet.

func Open

func Open(name string) (afero.File, error)

Open opens a file, returning it or an error, if any happens.

func ReadFile

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

ReadFile is a shorthand for fs.Open followed by io.ReadAll. It returns the first encountered non-nil error.

func SetGlobalFileSystem

func SetGlobalFileSystem(fs afero.Fs)

SetGlobalFileSystem sets the FS to use by all the functions in this package. It allows to switch between OS FS and mock FS during tests. This function is not thread safe and should not be called concurrently.

func Stat

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

Stat returns a FileInfo describing the named file, or an error, if any happens.

Types

This section is empty.

Jump to

Keyboard shortcuts

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