fs

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package fs contains file iostream related utilities

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Save

func Save[T io.Reader](r T, folder, file string) error

Save read content from r and write it into file located in folder.

func With

func With(name string, flag int, perm os.FileMode, fn func(*os.File) error) error

With open file named as name with permission perm and flags flag, then consume the file in fn, finally close this file

func WithCloser

func WithCloser[T any](r T, close func(T) error, action func(T) error) error

WithCloser consume resource r in action and close it finally.

func WithOpen

func WithOpen[T any](open func() (T, error), close func(T) error, action func(T) error) error

WithOpen open resource with open function, consume it in action and close it finally.

func WithReadCloser

func WithReadCloser(rc io.ReadCloser, action func([]byte) error) (err error)

WithReadCloser read content in resource rc in action and close it finally.

func WithReader

func WithReader(name string, fn func(*os.File) error) error

WithReader reads file with name and consume it in fn and close it finally.

func WithScanner

func WithScanner[T any](name string, maximum int, stoppable func(line string) (bool, T)) (found bool, value T, err error)

WithScanner reads file into line and invoke fn one by one

func WithWriteCloser

func WithWriteCloser(wc io.WriteCloser, action func(wc io.WriteCloser) error) (err error)

WithWriteCloser write anything in action to rc and close rc finally.

func WithWriter

func WithWriter(name string, fn func(*os.File) error) error

WithWriter open file with name for writing and consume the opened file in fn

Types

This section is empty.

Jump to

Keyboard shortcuts

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