1
0
mirror of https://github.com/golang/go synced 2024-10-03 16:31:27 -06:00
go/src/bufio
Brad Fitzpatrick ee2ecc4552 bufio: add Reader.Discard
Reader.Discard is the complement to Peek. It discards the next n bytes
of input.

We already have Reader.Buffered to see how many bytes of data are
sitting available in memory, and Reader.Peek to get that that buffer
directly. But once you're done with the Peek'd data, you can't get rid
of it, other than Reading it.
Both Read and io.CopyN(ioutil.Discard, bufReader, N) are relatively
slow. People instead resort to multiple blind ReadByte calls, just to
advance the internal b.r variable.

I've wanted this previously, several people have asked for it in the
past on golang-nuts/dev, and somebody just asked me for it again in a
private email. There are a few places in the standard library we'd use
it too.

Change-Id: I85dfad47704a58bd42f6867adbc9e4e1792bc3b0
Reviewed-on: https://go-review.googlesource.com/2260
Reviewed-by: Russ Cox <rsc@golang.org>
2015-01-07 06:37:57 +00:00
..
bufio_test.go bufio: add Reader.Discard 2015-01-07 06:37:57 +00:00
bufio.go bufio: add Reader.Discard 2015-01-07 06:37:57 +00:00
example_test.go build: move package sources from src/pkg to src 2014-09-08 00:08:51 -04:00
export_test.go build: move package sources from src/pkg to src 2014-09-08 00:08:51 -04:00
scan_test.go bufio: remove unused 'panicked' variable from test 2014-11-06 15:22:29 +11:00
scan.go bufio: fix reading of many blank lines in a row 2014-11-05 22:50:24 -05:00