iotest

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 5, 2026 License: BSD-3-Clause Imports: 2 Imported by: 0

Documentation

Overview

Package iotest implements Readers and Writers useful mainly for testing.

Index

Constants

This section is empty.

Variables

View Source
var ErrTimeout = errors.New("timeout")

ErrTimeout is a fake timeout error.

Functions

func DataErrReader

func DataErrReader(r io.Reader) io.Reader

DataErrReader changes the way errors are handled by a Reader. Normally, a Reader returns an error (typically EOF) from the first Read call after the last piece of data is read. DataErrReader wraps a Reader and changes its behavior so the final error is returned along with the final data, instead of in the first call after the final data.

func ErrReader

func ErrReader(err error) io.Reader

ErrReader returns an io.Reader that returns 0, err from all Read calls.

func HalfReader

func HalfReader(r io.Reader) io.Reader

HalfReader returns a Reader that implements Read by reading half as many requested bytes from r.

func OneByteReader

func OneByteReader(r io.Reader) io.Reader

OneByteReader returns a Reader that implements each non-empty Read by reading one byte from r.

func TimeoutReader

func TimeoutReader(r io.Reader) io.Reader

TimeoutReader returns ErrTimeout on the second read with no data. Subsequent calls to read succeed.

func TruncateWriter

func TruncateWriter(w io.Writer, n int64) io.Writer

TruncateWriter returns a Writer that writes to w but stops silently after n bytes.

Types

This section is empty.

Jump to

Keyboard shortcuts

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