file

package
v2.2.26 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Open opens a file for reading
	Open = ioresult.Eitherize1(os.Open)
	// Create opens a file for writing
	Create = ioresult.Eitherize1(os.Create)
	// ReadFile reads the context of a file
	ReadFile = ioresult.Eitherize1(os.ReadFile)
)
View Source
var (
	// CreateTemp created a temp file with proper parametrization
	CreateTemp = ioresult.Eitherize2(os.CreateTemp)
)

Functions

This section is empty.

Types

type IOResult

type IOResult[T any] = ioresult.IOResult[T]

func Close

func Close[C io.Closer](c C) IOResult[any]

Close closes an object

func Mkdir

func Mkdir(path string, perm os.FileMode) IOResult[string]

Mkdir create a directory, see os.Mkdir

func MkdirAll

func MkdirAll(path string, perm os.FileMode) IOResult[string]

MkdirAll create a sequence of directories, see os.MkdirAll

func ReadAll

func ReadAll[R io.ReadCloser](acquire IOResult[R]) IOResult[[]byte]

ReadAll uses a generator function to create a stream, reads it and closes it

func Remove

func Remove(name string) IOResult[string]

Remove removes a file by name

func WithTempFile

func WithTempFile[A any](f Kleisli[*os.File, A]) IOResult[A]

WithTempFile creates a temporary file, then invokes a callback to create a resource based on the file, then close and remove the temp file

type Kleisli

type Kleisli[A, B any] = ioresult.Kleisli[A, B]

func Write

func Write[R any, W io.WriteCloser](acquire IOResult[W]) Kleisli[Kleisli[W, R], R]

Write uses a generator function to create a stream, writes data to it and closes it

func WriteFile

func WriteFile(dstName string, perm os.FileMode) Kleisli[[]byte, []byte]

WriteFile writes a data blob to a file

type Operator

type Operator[A, B any] = ioresult.Operator[A, B]

func WriteAll

func WriteAll[W io.WriteCloser](data []byte) Operator[W, []byte]

WriteAll uses a generator function to create a stream, writes data to it and closes it

Jump to

Keyboard shortcuts

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