ioext

package
v5.7.0 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2022 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrLimitedReaderEOF is an error returned by LimitedReader to give feedback to the fact that we did not hit an
	// EOF of the Reader but hit the limit imposed by the LimitedReader.
	ErrLimitedReaderEOF = errors.New("LimitedReader EOF: limit reached")
)

Functions

This section is empty.

Types

type LimitedReader

type LimitedReader struct {
	R io.Reader
	N int64 // bytes allotted
}

A LimitedReader reads from R but limits the amount of data returned to just N bytes. Each call to Read updates N to reflect the new amount remaining. Read returns ErrLimitedReaderEOF when N <= 0 or when the underlying R returns EOF. Unlike the std io.LimitedReader this provides feedback that the limit was reached through the returned error.

func LimitReader

func LimitReader(r io.Reader, n int64) *LimitedReader

LimitReader returns a LimitedReader that reads from r but stops with ErrLimitedReaderEOF after n bytes.

func (*LimitedReader) Read

func (l *LimitedReader) Read(p []byte) (n int, err error)

Jump to

Keyboard shortcuts

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