Documentation ¶
Index ¶
- func Copy(t testing.TB, dst io.Writer, src io.Reader) (written int64)
- func CopyBuffer(t testing.TB, dst io.Writer, src io.Reader, buf []byte) (written int64)
- func CopyN(t testing.TB, dst io.Writer, src io.Reader, n int64) (written int64)
- func ReadAll(t testing.TB, r io.Reader) []byte
- func ReadAtLeast(t testing.TB, r io.Reader, buf []byte, min int) (n int)
- func ReadFull(t testing.TB, r io.Reader, buf []byte) (n int)
- func WriteString(t testing.TB, w io.Writer, s string) (n int)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Copy ¶
Copy copies from src to dst until either EOF is reached on src or an error occurs. It returns the number of bytes copied and the first error encountered while copying, if any.
A successful Copy returns err == nil, not err == EOF. Because Copy is defined to read from src until EOF, it does not treat an EOF from Read as an error to be reported.
If src implements [WriterTo], the copy is implemented by calling src.WriteTo(dst). Otherwise, if dst implements [ReaderFrom], the copy is implemented by calling dst.ReadFrom(src).
func CopyBuffer ¶
CopyBuffer is identical to Copy except that it stages through the provided buffer (if one is required) rather than allocating a temporary one. If buf is nil, one is allocated; otherwise if it has zero length, CopyBuffer panics.
If either src implements [WriterTo] or dst implements [ReaderFrom], buf will not be used to perform the copy.
func CopyN ¶
CopyN copies n bytes (or until an error) from src to dst. It returns the number of bytes copied and the earliest error encountered while copying. On return, written == n if and only if err == nil.
If dst implements [ReaderFrom], the copy is implemented using it.
func ReadAll ¶
ReadAll reads from r until an error or EOF and returns the data it read. A successful call returns err == nil, not err == EOF. Because ReadAll is defined to read from src until EOF, it does not treat an EOF from Read as an error to be reported.
func ReadAtLeast ¶
ReadAtLeast reads from r into buf until it has read at least min bytes. It returns the number of bytes copied and an error if fewer bytes were read. The error is EOF only if no bytes were read. If an EOF happens after reading fewer than min bytes, ReadAtLeast returns [ErrUnexpectedEOF]. If min is greater than the length of buf, ReadAtLeast returns [ErrShortBuffer]. On return, n >= min if and only if err == nil. If r returns an error having read at least min bytes, the error is dropped.
func ReadFull ¶
ReadFull reads exactly len(buf) bytes from r into buf. It returns the number of bytes copied and an error if fewer bytes were read. The error is EOF only if no bytes were read. If an EOF happens after reading some but not all the bytes, ReadFull returns [ErrUnexpectedEOF]. On return, n == len(buf) if and only if err == nil. If r returns an error having read at least len(buf) bytes, the error is dropped.
Types ¶
This section is empty.