iotools

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2019 License: CC0-1.0 Imports: 2 Imported by: 5

Documentation

Index

Constants

View Source
const EOFReader = eofreader(0)

EOFReader is an io.Reader with Read always giving an io.EOF.

Variables

This section is empty.

Functions

func Drain

func Drain(r io.Reader) (int64, error)

Drain reads from r until either io.EOF is reached on r or an error occurs. It returns the number of bytes read and the first error encountered while reading, if any. Note that on completing successful drain the second return value is nil and not io.EOF. Because Drain is defined to read from r until io.EOF, it does not treat an io.EOF from Read as an error to be reported.

func ExactReader

func ExactReader(r io.Reader, n int64) io.Reader

ExactReader returns an io.Reader that reads from r but stops with io.EOF after n bytes, and returns an io.ErrUnexpectedEOF if io.EOF occurs before n bytes have been read.

Types

type ByteCountWriter

type ByteCountWriter struct {
	W io.Writer // The wrapped writer
	N int64     // The number of bytes written to the writer
}

ByteCountWriter wraps an io.Writer and keeps track of the number of bytes that have been written to the wrapped writer.

func (*ByteCountWriter) Size

func (w *ByteCountWriter) Size() int64

Size returns the number of bytes that have been written to the writer.

func (*ByteCountWriter) Write

func (w *ByteCountWriter) Write(p []byte) (int, error)

Write writes len(p) bytes from p to the underlying data stream. It returns the number of bytes written from p (0 <= n <= len(p)) and any error encountered that caused the write to stop early.

Jump to

Keyboard shortcuts

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