Documentation ¶
Overview ¶
Package peekabuf offers buffers with the capability to be peeked without side effects on the unread functionality. Along with that, it returns a special `EOF` rune instead of an error if it reaches the end of the buffer.
Index ¶
Constants ¶
const EOF = rune(-1)
EOF is a special rune indicating the end of the buffer.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type RuneReader ¶
type RuneReader struct {
// contains filtered or unexported fields
}
RuneReader is a buffered reader which operates on runes.
func NewRuneReader ¶
func NewRuneReader(reader io.Reader) *RuneReader
NewRuneReader creates a new instance of a RuneReader.
func (*RuneReader) Peek ¶
func (rr *RuneReader) Peek(n uint) ([]rune, error)
Peek returns the desired amount of runes without removing them from the buffer. If there are not enough runes in the buffer, it returns as many as possible with an EOF rune at the end.
func (*RuneReader) Read ¶
func (rr *RuneReader) Read() rune
Read reads and removes the next rune from the buffer and returns it. If there are no runes left in the buffer, it returns an EOF.
func (*RuneReader) Unread ¶
func (rr *RuneReader) Unread()
Unread puts back the last read rune to the front of the buffer. It reverts the Read function. If there was no call to Read, it can't unread the rune and the call to this function is a no op.