Documentation
¶
Overview ¶
Package fs contains file iostream related utilities
Index ¶
- func Save[T io.Reader](r T, folder, file string) error
- func With(name string, flag int, perm os.FileMode, fn func(*os.File) error) error
- func WithCloser[T any](r T, close func(T) error, action func(T) error) error
- func WithOpen[T any](open func() (T, error), close func(T) error, action func(T) error) error
- func WithReadCloser(rc io.ReadCloser, action func([]byte) error) (err error)
- func WithReader(name string, fn func(*os.File) error) error
- func WithScanner[T any](name string, maximum int, stoppable func(line string) (bool, T)) (found bool, value T, err error)
- func WithWriteCloser(wc io.WriteCloser, action func(wc io.WriteCloser) error) (err error)
- func WithWriter(name string, fn func(*os.File) error) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func With ¶
With open file named as name with permission perm and flags flag, then consume the file in fn, finally close this file
func WithCloser ¶
WithCloser consume resource r in action and close it finally.
func WithOpen ¶
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 ¶
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.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.