Unreader to unread bytes

This commit is contained in:
Jae Kwon
2014-12-29 15:14:54 -08:00
parent 946fa21dc7
commit 5bace5cce8
19 changed files with 84 additions and 57 deletions

View File

@ -18,6 +18,16 @@ func ReadByte(r io.Reader, n *int64, err *error) byte {
return buf[0]
}
// NOTE: may end up advancing the reader upon error.
func PeekByte(r Unreader, n *int64, err *error) byte {
byte_ := ReadByte(r, n, err)
if *err != nil {
return 0
}
*err = r.UnreadByte()
return byte_
}
// Int8
func WriteInt8(i int8, w io.Writer, n *int64, err *error) {