readerutil

package
v0.0.0-...-e0e03bd Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2016 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package readerutil contains io.Reader types.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

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
var (
	// r is the io.Reader we'd like to count read from.
	r  = strings.NewReader("Hello world")
	v  = expvar.NewInt("read-bytes")
	sw = NewStatsReader(v, r)
)
// Read from the wrapped io.Reader, StatReader will count the bytes.
io.Copy(ioutil.Discard, sw)
fmt.Printf("Read %s bytes\n", v.String())
Output:

Read 11 bytes

Types

type ReadSeekCloser

type ReadSeekCloser interface {
	io.Reader
	io.Seeker
	io.Closer
}

A ReadSeekCloser can Read, Seek, and Close.

type ReaderAtCloser

type ReaderAtCloser interface {
	io.ReaderAt
	io.Closer
}

type SizeReaderAt

type SizeReaderAt interface {
	Size() int64
	io.ReaderAt
}

A SizeReaderAt is a ReaderAt with a Size method.

An io.SectionReader implements SizeReaderAt.

func NewMultiReaderAt

func NewMultiReaderAt(parts ...SizeReaderAt) SizeReaderAt

NewMultiReaderAt is like io.MultiReader but produces a ReaderAt (and Size), instead of just a reader.

Jump to

Keyboard shortcuts

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