stream
is a Go library which provides a buffered reader with convenient
functions.
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")
If you have an idea or a question, email me at khaelin@gmail.com.