• Joe Tsai's avatar
    bytes, string: add Reset method to Reader · e88f8902
    Joe Tsai authored
    Currently, there is no easy allocation-free way to turn a
    []byte or string into an io.Reader. Thus, we add a Reset method
    to bytes.Reader and strings.Reader to allow the reuse of these
    Readers with another []byte or string.
    
    This is consistent with the fact that many standard library io.Readers
    already support a Reset method of some type:
    	bufio.Reader
    	flate.Reader
    	gzip.Reader
    	zlib.Reader
    	debug/dwarf.LineReader
    	bytes.Buffer
    	crypto/rc4.Cipher
    
    Fixes #15033
    
    Change-Id: I456fd1af77af6ef0b4ac6228b058ac1458ff3d19
    Reviewed-on: https://go-review.googlesource.com/21386Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
    Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
    TryBot-Result: Gobot Gobot <gobot@golang.org>
    e88f8902
reader.go 3.35 KB