readerutils

package
v0.19.14 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2025 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ChainedCloser

func ChainedCloser(this io.ReadCloser, other io.Closer) io.ReadCloser

func NewCleanupReadCloser added in v0.8.6

func NewCleanupReadCloser(r io.ReadCloser, cleanup func() error) io.ReadCloser

NewCleanupReadCloser creates an io.ReadCloser that calls the cleanup function after closing the original closer. This is useful for cleaning up temporary files.

func NewCountingReader added in v0.18.0

func NewCountingReader(rc io.ReadCloser, bytesRead *atomic.Uint64) io.ReadCloser

NewCountingReader creates a wrapper around io.ReadCloser that tracks the total bytes read using an atomic counter.

func WriterToReader

func WriterToReader(reader io.Reader, writerSource func(writer io.Writer) io.WriteCloser) io.Reader

WriterToReader transforms an io.Writer that is provided by the given function into an io.Reader.

Types

type CleanupReadCloser added in v0.8.6

type CleanupReadCloser struct {
	// contains filtered or unexported fields
}

CleanupReadCloser wraps an io.ReadCloser and a function to be called on Close.

func (*CleanupReadCloser) Close added in v0.8.6

func (f *CleanupReadCloser) Close() error

Close closes the reader and calls the provided function.

func (*CleanupReadCloser) Read added in v0.8.6

func (f *CleanupReadCloser) Read(p []byte) (int, error)

Read delegates to the underlying reader.

type CloserFunc

type CloserFunc func() error

CloserFunc is the basic Close method defined in io.Closer.

func (CloserFunc) Close

func (fn CloserFunc) Close() error

Close performs close operation by the CloserFunc.

type CountingReader added in v0.18.0

type CountingReader struct {
	// contains filtered or unexported fields
}

CountingReader is a wrapper around io.ReadCloser that tracks the total number of bytes read using an atomic counter.

func (*CountingReader) Close added in v0.18.0

func (c *CountingReader) Close() error

func (*CountingReader) Read added in v0.18.0

func (c *CountingReader) Read(p []byte) (n int, err error)

type LatencyReader added in v0.8.6

type LatencyReader struct {
	Reader io.Reader
	Delay  time.Duration
}

LatencyReader wraps an io.Reader and introduces a delay before each read.

func (*LatencyReader) Read added in v0.8.6

func (l *LatencyReader) Read(p []byte) (int, error)

Jump to

Keyboard shortcuts

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