peekingReader

package module
v0.0.0-...-257fb6f Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2017 License: MIT Imports: 4 Imported by: 11

README

peekingReader

A buffered and in-memory io.Reader that can Peek and Read a specified number of bytes

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReadUntil

func ReadUntil(r Reader, endAt byte) ([]byte, error)

ReadUntil reads until a particular byte is reached

func ReadUntilAny

func ReadUntilAny(r Reader, endAtAny []byte) ([]byte, error)

ReadUntilAny reads until any byte in the endAtAny array is reached

func SkipSpaces

func SkipSpaces(r Reader) error

SkipSpaces skips all subsequent space characters. This includes " ", "\t", "\f", "\n", "\r", "\x00"

func SkipSubsequent

func SkipSubsequent(r Reader, skip []byte) (bool, error)

SkipSubsequent skips all consecutive characters in any order

Types

type Reader

type Reader interface {
	Peek(n int) ([]byte, error)
	ReadByte() (byte, error)
	ReadBytes(size int) ([]byte, error)
	ReadRune() (rune, int, error)
	io.Reader
}

Reader is an io.Reader which can also Peek and Read n number of bytes. Also includes a convenience function to read one byte

func NewBufReader

func NewBufReader(r io.Reader) Reader

NewBufReader returns a PeekingReader.Reader. It uses an underlying *bufio.Reader to implement its capability.

func NewMemReader

func NewMemReader(b []byte) Reader

NewMemReader returns a PeekingReader.Reader. It uses an underlying []byte buffer to provide its capability

Jump to

Keyboard shortcuts

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