package file
import "github.com/IBM/fp-go/ioeither/file"
Index ¶
- Variables
- func Close[C io.Closer](c C) IOE.IOEither[error, any]
- func Mkdir(path string, perm os.FileMode) IOE.IOEither[error, string]
- func MkdirAll(path string, perm os.FileMode) IOE.IOEither[error, string]
- func ReadAll[R io.ReadCloser](acquire IOE.IOEither[error, R]) IOE.IOEither[error, []byte]
- func Remove(name string) IOE.IOEither[error, string]
- func WithTempFile[A any](f func(*os.File) IOE.IOEither[error, A]) IOE.IOEither[error, A]
- func Write[R any, W io.WriteCloser](acquire IOE.IOEither[error, W]) func(use func(W) IOE.IOEither[error, R]) IOE.IOEither[error, R]
- func WriteAll[W io.WriteCloser](data []byte) func(acquire IOE.IOEither[error, W]) IOE.IOEither[error, []byte]
- func WriteFile(dstName string, perm os.FileMode) func([]byte) IOE.IOEither[error, []byte]
Variables ¶
var ( // Open opens a file for reading Open = IOE.Eitherize1(os.Open) // Create opens a file for writing Create = IOE.Eitherize1(os.Create) // ReadFile reads the context of a file ReadFile = IOE.Eitherize1(os.ReadFile) )
var ( // CreateTemp created a temp file with proper parametrization CreateTemp = IOE.Eitherize2(os.CreateTemp) )
Functions ¶
func Close ¶
Close closes an object
func Mkdir ¶
Mkdir create a directory, see os.Mkdir
func MkdirAll ¶
MkdirAll create a sequence of directories, see os.MkdirAll
func ReadAll ¶
ReadAll uses a generator function to create a stream, reads it and closes it
func Remove ¶
Remove removes a file by name
func WithTempFile ¶
WithTempFile creates a temporary file, then invokes a callback to create a resource based on the file, then close and remove the temp file
func Write ¶
func Write[R any, W io.WriteCloser](acquire IOE.IOEither[error, W]) func(use func(W) IOE.IOEither[error, R]) IOE.IOEither[error, R]
Write uses a generator function to create a stream, writes data to it and closes it
func WriteAll ¶
func WriteAll[W io.WriteCloser](data []byte) func(acquire IOE.IOEither[error, W]) IOE.IOEither[error, []byte]
WriteAll uses a generator function to create a stream, writes data to it and closes it
func WriteFile ¶
WriteFile writes a data blob to a file
Source Files ¶
dir.go file.go readall.go tempfile.go write.go
- Version
- v1.0.151 (latest)
- Published
- Nov 23, 2024
- Platform
- linux/amd64
- Imports
- 7 packages
- Last checked
- 5 months ago –
Tools for package owners.