mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
add io.ByteReader.
add testing/iotest package. make bufio return error on short write. R=r DELTA=423 (208 added, 154 deleted, 61 changed) OCL=28997 CL=28999
This commit is contained in:
parent
6b942c68cc
commit
be869ba4d6
7 changed files with 269 additions and 210 deletions
|
|
@ -42,13 +42,17 @@ func (b *ByteBuffer) Len() int {
|
|||
// Truncate discards all but the first n unread bytes from the buffer.
|
||||
// It is an error to call b.Truncate(n) with n > b.Len().
|
||||
func (b *ByteBuffer) Truncate(n int) {
|
||||
if n == 0 {
|
||||
// Reuse buffer space.
|
||||
b.off = 0;
|
||||
}
|
||||
b.buf = b.buf[0 : b.off + n];
|
||||
}
|
||||
|
||||
// Reset resets the buffer so it has no content.
|
||||
// b.Reset() is the same as b.Truncate(0).
|
||||
func (b *ByteBuffer) Reset() {
|
||||
b.buf = b.buf[0 : b.off];
|
||||
b.Truncate(0);
|
||||
}
|
||||
|
||||
// Write appends the contents of p to the buffer. The return
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue