Documentation ¶
Overview ¶
Package io provides io functions
SPDX-License-Identifier: Apache-2.0
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ErrorReader ¶
type ErrorReader struct {
// contains filtered or unexported fields
}
ErrorReader is an io.Reader that returns a non-eof error after some input bytes have been read. This is mostly useful for testing, where the input bytes can get the code being tested to reach a desired state first, then verify that code correctly handles non-eof errors.
When the error is returned, the number of bytes is always 0. If there is at least one byte remaining to read and a call to read asks for more bytes than remain, the result of the call is (num remaining bytes, nil), and the next call to read returns (0, error). If the input is an empty slice, the first call to read returns (0, error).
Once all input bytes have been read and the error has been returned, any further calls to read will continue to return (0, error).
func NewErrorReader ¶
func NewErrorReader(input []byte, err error) *ErrorReader
NewErrorReader constructs an ErrorReader from a set of input bytes and an error
type ErrorWriter ¶
type ErrorWriter struct {
// contains filtered or unexported fields
}
ErrorWriter is the Writer analog to ErrorReader, it returns a non-eof error after some output bytes have been written. A preallocated slice of bytes tracks the bytes written, so the caller can compare.
func NewErrorWriter ¶
func NewErrorWriter(count int, err error) *ErrorWriter
NewErrorWriter constructs an ErrorWriter from a count of output bytes to allow and an error
func (*ErrorWriter) Output ¶
func (w *ErrorWriter) Output() []byte
Output provides the output written to the write so far, for comparison