ioutil

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReadBytesLimitedPrealloc

func ReadBytesLimitedPrealloc(r io.Reader, size uint64) ([]byte, error)

func ReadStringLimitedPrealloc

func ReadStringLimitedPrealloc(r io.Reader, size uint64) (string, error)

Types

type ByteReader

type ByteReader interface {
	io.Reader
	io.ByteReader
}

func TeeReader

func TeeReader(r ByteReader, w io.Writer) ByteReader

TeeReader returns a [Reader] that writes to w what it reads from r. All reads from r performed through it are matched with corresponding writes to w. There is no internal buffering - the write must complete before the read completes. Any error encountered while writing is reported as a read error.

type SubReader

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

SubReader is a zero-copy reader over a []byte. All sub-reader views share the same backing slice; no copies are made on fork or sub-view creation.

*SubReader is a live, shared cursor: mutations through one pointer are visible to all holders. Copying the value (SubReader, not *SubReader) snapshots the cursor at its current position — equivalent to a fork — without any allocation. Callers that want an independent cursor should copy the value rather than the pointer.

func NewSubReader

func NewSubReader(data []byte) *SubReader

NewSubReader creates a SubReader over data. data is not copied.

func ReadFrom

func ReadFrom(r io.Reader) (*SubReader, error)

ReadFrom reads all bytes from r and returns a SubReader over them.

func (*SubReader) Available

func (b *SubReader) Available() int

Available returns the number of bytes remaining to be read.

func (*SubReader) Consumed

func (b *SubReader) Consumed() int

Consumed returns the total bytes advanced via Read or Skip since creation.

func (*SubReader) Deflate

func (b *SubReader) Deflate() (*SubReader, int, error)

Deflate decompresses the remaining bytes using DEFLATE and returns a new SubReader over the decompressed data and the decompressed size.

func (*SubReader) Empty

func (b *SubReader) Empty() bool

Empty reports whether all bytes have been consumed.

func (*SubReader) HasAtLeast

func (b *SubReader) HasAtLeast(n int) bool

HasAtLeast reports whether at least n bytes remain.

func (*SubReader) Peek

func (b *SubReader) Peek(w io.Writer, n int) error

Peek writes the next n bytes to w without advancing the position.

func (*SubReader) Read

func (b *SubReader) Read(p []byte) (n int, err error)

func (*SubReader) ReadByte

func (b *SubReader) ReadByte() (byte, error)

ReadByte implements io.ByteReader. Returns io.EOF if no bytes remain.

func (*SubReader) Skip

func (b *SubReader) Skip(n int) error

Skip advances the position by n bytes.

func (*SubReader) SubReader

func (b *SubReader) SubReader(offset uint64, size uint64) (*SubReader, error)

SubReader returns a new SubReader covering [current+offset, current+offset+size). This does NOT advance the current position.

func (*SubReader) SubReaderOffset

func (b *SubReader) SubReaderOffset(offset uint64) (*SubReader, error)

SubReaderOffset returns a new SubReader starting at current+offset extending to the end of this reader's data. This does NOT advance the current position.

Jump to

Keyboard shortcuts

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