> On Tuesday, 10 February 2015 09:12:37 UTC+11, Scott Pakin wrote:
> > To implement a particular interface from the standard library (i.e., one I
> > didn't define myself), a method I'm writing needs to accept an io.Reader.
> > However, I'd like to be able to exploit all the nice methods defined on
> > bufio.Reader. I just don't want the caller to know or care that my
> > function does that. What should I do? I'm assuming that there are no
> > guarantees about the state of the underlying io.Reader after reading from
> > a bufio.Reader that wraps it, but I'd be happy to be wrong about that.
* Dave Cheney <
da...@cheney.net> [150209 18:20]:
> There are no guarantees provided. bufio.Reader may consume some, none, or
> all of the contents of the underlying reader.
However, if the caller might pass in a bufio.Reader, and you are happy
to take advantage of that if so, but do without if not, you can always
check with something like:
var b, ok = r.(*bufio.Reader)
and then use b if ok is true.
...Marvin