ioExt

package
v0.0.0-...-a794c3e Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendToFile

func AppendToFile(path string, data []byte) error

AppendToFile appends data to a file, creating the file if it doesn't exist.

func CopyWithProgress

func CopyWithProgress(dst io.Writer, src io.Reader, progressFn func(written int64)) (int64, error)

CopyWithProgress copies data from src to dst, reporting progress periodically. It returns the number of bytes copied and the first error encountered, if any.

func DirExists

func DirExists(path string) bool

DirExists checks if a directory exists.

func FileExists

func FileExists(path string) bool

FileExists checks if a file exists and is not a directory.

func MultiReadCloser

func MultiReadCloser(readers ...io.ReadCloser) io.ReadCloser

MultiReadCloser returns an io.ReadCloser that's the logical concatenation of the provided input readers. They're read sequentially, and Close() closes all readers.

func ReadFileString

func ReadFileString(path string) (string, error)

ReadFileString reads the entire contents of a file and returns it as a string. If the file cannot be read, it returns an error.

func SafeClose

func SafeClose(c io.Closer) error

SafeClose attempts to close the closer and returns the error if any. It's useful in defer statements where you might want to track the close error.

func WalkFiles

func WalkFiles(root string, walkFn func(path string, info fs.FileInfo) error) error

WalkFiles recursively walks through a directory and calls the walkFn for each file. Directories are skipped.

func WriteFileWithDirs

func WriteFileWithDirs(path string, data []byte, perm os.FileMode) error

WriteFileWithDirs writes data to a file, creating all necessary directories. If the file already exists, it will be truncated.

Types

This section is empty.

Jump to

Keyboard shortcuts

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