mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
Add ReadByte to bytebuffer
R=rsc APPROVED=rsc DELTA=24 (24 added, 0 deleted, 0 changed) OCL=30459 CL=30540
This commit is contained in:
parent
efc4088ccd
commit
08aab44e48
2 changed files with 24 additions and 0 deletions
|
|
@ -102,6 +102,17 @@ func (b *ByteBuffer) Read(p []byte) (n int, err os.Error) {
|
|||
return n, nil
|
||||
}
|
||||
|
||||
// ReadByte reads and returns the next byte from the buffer.
|
||||
// If no byte is available, it returns error ErrEOF.
|
||||
func (b *ByteBuffer) ReadByte() (c byte, err os.Error) {
|
||||
if b.off >= len(b.buf) {
|
||||
return 0, ErrEOF;
|
||||
}
|
||||
c = b.buf[b.off];
|
||||
b.off++;
|
||||
return c, nil;
|
||||
}
|
||||
|
||||
// NewByteBufferFromArray creates and initializes a new ByteBuffer
|
||||
// with buf as its initial contents.
|
||||
func NewByteBufferFromArray(buf []byte) *ByteBuffer {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue