Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
golang
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
golang
Commits
c59dc485
Commit
c59dc485
authored
Feb 08, 2012
by
Rob Pike
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bytes.Buffer: return error in WriteTo if buffer is not drained
R=rsc CC=golang-dev
https://golang.org/cl/5642065
parent
3fce00d9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
1 deletion
+8
-1
buffer.go
src/pkg/bytes/buffer.go
+8
-1
No files found.
src/pkg/bytes/buffer.go
View file @
c59dc485
...
...
@@ -182,14 +182,21 @@ func makeSlice(n int) []byte {
func
(
b
*
Buffer
)
WriteTo
(
w
io
.
Writer
)
(
n
int64
,
err
error
)
{
b
.
lastRead
=
opInvalid
if
b
.
off
<
len
(
b
.
buf
)
{
nBytes
:=
b
.
Len
()
m
,
e
:=
w
.
Write
(
b
.
buf
[
b
.
off
:
])
if
m
>
nBytes
{
panic
(
"bytes.Buffer.WriteTo: invalid Write count"
)
}
b
.
off
+=
m
n
=
int64
(
m
)
if
e
!=
nil
{
return
n
,
e
}
//
otherwise all bytes were
written, by definition of
//
all bytes should have been
written, by definition of
// Write method in io.Writer
if
m
!=
nBytes
{
return
n
,
io
.
ErrShortWrite
}
}
// Buffer is now empty; reset.
b
.
Truncate
(
0
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment