Package readerutil
Overview ▹
Index ▹
func NewFakeSeeker ¶
func NewFakeSeeker(r io.Reader, size int64) io.ReadSeeker
NewFakeSeeker returns a ReadSeeker that can pretend to Seek (based on the provided total size of the reader's content), but any reads will fail if the fake seek position doesn't match reality.
func NewStatsReadSeeker ¶
func NewStatsReadSeeker(v *expvar.Int, rs io.ReadSeeker) io.ReadSeeker
NewReaderStats returns an io.ReadSeeker that will have the number of bytes read from rs added to v.
func NewStatsReader ¶
func NewStatsReader(v *expvar.Int, r io.Reader) io.Reader
NewReaderStats returns an io.Reader that will have the number of bytes read from r added to v.
▹ Example
func Size ¶
func Size(r io.Reader) (size int64, ok bool)
Size tries to determine the length of r. If r is an io.Seeker, Size may seek to guess the length.
type CountingReader ¶
CountingReader wraps a Reader, incrementing N by the number of bytes read. No locking is performed.
type CountingReader struct { Reader io.Reader N *int64 }
func (CountingReader) Read ¶
func (cr CountingReader) Read(p []byte) (n int, err error)
type ReadSeekCloser ¶
A ReadSeekCloser can Read, Seek, and Close.
type ReadSeekCloser interface { io.Reader io.Seeker io.Closer }
type ReaderAtCloser ¶
type ReaderAtCloser interface { io.ReaderAt io.Closer }
type SizeReaderAt ¶
A SizeReaderAt is a ReaderAt with a Size method.
An io.SectionReader implements SizeReaderAt.
type SizeReaderAt interface { Size() int64 io.ReaderAt }
func NewMultiReaderAt ¶
func NewMultiReaderAt(parts ...SizeReaderAt) SizeReaderAt
NewMultiReaderAt is like io.MultiReader but produces a ReaderAt (and Size), instead of just a reader.
Subdirectories
Name | Synopsis |
---|---|
.. | |
singlereader | package singlereader provides Open and Close operations, reusing existing file descriptors when possible. |