io

package
v1.11.8 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrReadLimitExceeded = errors.New("read limit exceeded")

Functions

This section is empty.

Types

type LimitedReadCloser

type LimitedReadCloser struct {
	R io.ReadCloser // underlying reader
	N int64         // max bytes remaining
	// contains filtered or unexported fields
}

LimitedReadCloser wraps an io.ReadCloser in limiting behavior using io.LimitedReader. It allows us to obtain the limit error at the time of close instead of just when writing.

func NewLimitedReadCloser

func NewLimitedReadCloser(r io.ReadCloser, n int64) *LimitedReadCloser

NewLimitedReadCloser returns a new LimitedReadCloser.

func (*LimitedReadCloser) Close

func (l *LimitedReadCloser) Close() (err error)

Close returns an ErrReadLimitExceeded when the wrapped reader exceeds the set limit for number of bytes. This is safe to call more than once but not concurrently.

func (*LimitedReadCloser) Read

func (l *LimitedReadCloser) 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