A convenient buffered reader.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.gitignore
LICENSE
README.mkd
stream.go
stream_test.go

README.mkd

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.

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.