ioutils

package
v0.0.0-...-37f5ccb Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2023 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewCancelReadCloser

func NewCancelReadCloser(ctx context.Context, in io.ReadCloser) io.ReadCloser

NewCancelReadCloser creates a wrapper that closes the ReadCloser when the context is cancelled. The returned io.ReadCloser must be closed when it is no longer needed.

func NewReadCloserWrapper

func NewReadCloserWrapper(r io.Reader, closer func() error) io.ReadCloser

NewReadCloserWrapper returns a new io.ReadCloser.

func NewReaderErrWrapper

func NewReaderErrWrapper(r io.Reader, closer func()) io.Reader

NewReaderErrWrapper returns a new io.Reader.

Types

type OnEOFReader

type OnEOFReader struct {
	Rc io.ReadCloser
	Fn func()
}

OnEOFReader wraps an io.ReadCloser and a function the function will run at the end of file or close the file.

func (*OnEOFReader) Close

func (r *OnEOFReader) Close() error

Close closes the file and run the function.

func (*OnEOFReader) Read

func (r *OnEOFReader) Read(p []byte) (n int, err error)

type ReadCloserWrapper

type ReadCloserWrapper struct {
	io.Reader
	// contains filtered or unexported fields
}

ReadCloserWrapper wraps an io.Reader, and implements an io.ReadCloser It calls the given callback function when closed. It should be constructed with NewReadCloserWrapper

func (*ReadCloserWrapper) Close

func (r *ReadCloserWrapper) Close() error

Close calls back the passed closer function

Jump to

Keyboard shortcuts

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