• Brad Fitzpatrick's avatar
    bufio: add Reader.Discard · ee2ecc45
    Brad Fitzpatrick authored
    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/2260Reviewed-by: 's avatarRuss Cox <rsc@golang.org>
    ee2ecc45
Name
Last commit
Last update
..
bufio.go Loading commit data...
bufio_test.go Loading commit data...
example_test.go Loading commit data...
export_test.go Loading commit data...
scan.go Loading commit data...
scan_test.go Loading commit data...