Help us shape the future of Go! Take the 2026 Go Developer Survey

stream

package module
v0.0.0-...-84cb134 Latest Latest
Warning

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

Go to latest
Published: May 1, 2017 License: ISC Imports: 2 Imported by: 3

README

# go-stream

## Introduction
`stream` is a Go library which provides a buffered reader with convenient
functions.

## Usage

The following example parses what looks like a HTTP header. Error return
values are ignored.

```go
s := stream.NewStreamBytes([]byte("Content-Length: 42\r\n"))
s.ReadUntilByteAndSkip(':') // yields []byte("Content-Length")
s.SkipWhile(func(b byte) bool {
	return b == ' ' || b == '\t'
})
s.ReadUntilAndSkip([]byte{'\r', '\n'}) // yields []byte("42")
```

## Contact
If you have an idea or a question, email me at <khaelin@gmail.com>.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Stream

type Stream struct {
	Reader io.Reader
	Buf    []byte
}

func NewStream

func NewStream(r io.Reader) *Stream

func NewStreamBytes

func NewStreamBytes(data []byte) *Stream

func (*Stream) IsEmpty

func (s *Stream) IsEmpty() (bool, error)

func (*Stream) Peek

func (s *Stream) Peek(n int) ([]byte, error)

func (*Stream) PeekUntil

func (s *Stream) PeekUntil(delim []byte) ([]byte, error)

func (*Stream) PeekUntilByte

func (s *Stream) PeekUntilByte(delim byte) ([]byte, error)

func (*Stream) PeekUpTo

func (s *Stream) PeekUpTo(n int) ([]byte, error)

func (*Stream) Read

func (s *Stream) Read(n int) ([]byte, error)

func (*Stream) ReadAll

func (s *Stream) ReadAll() ([]byte, error)

func (*Stream) ReadUntil

func (s *Stream) ReadUntil(delim []byte) ([]byte, error)

func (*Stream) ReadUntilAndSkip

func (s *Stream) ReadUntilAndSkip(delim []byte) ([]byte, error)

func (*Stream) ReadUntilByte

func (s *Stream) ReadUntilByte(delim byte) ([]byte, error)

func (*Stream) ReadUntilByteAndSkip

func (s *Stream) ReadUntilByteAndSkip(delim byte) ([]byte, error)

func (*Stream) ReadWhile

func (s *Stream) ReadWhile(fn func(byte) bool) ([]byte, error)

func (*Stream) Skip

func (s *Stream) Skip(n int) error

func (*Stream) SkipByte

func (s *Stream) SkipByte(b byte) (bool, error)

func (*Stream) SkipBytes

func (s *Stream) SkipBytes(bs []byte) (bool, error)

func (*Stream) SkipWhile

func (s *Stream) SkipWhile(fn func(byte) bool) error

func (*Stream) StartsWithByte

func (s *Stream) StartsWithByte(b byte) (bool, error)

func (*Stream) StartsWithBytes

func (s *Stream) StartsWithBytes(bs []byte) (bool, error)

Jump to

Keyboard shortcuts

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