networking - golang: how to release a net.Conn from a bfio.Reader -
in go have net.conn wrap bufio.reader. want read , parse number of lines reader, , obtain control on net.conn, obtaining temporary data reader might still have buffered. there easy way it?
you can buffered data *bufio.reader
using following code:
p, _ := br.peek(br.buffered())
where p
[]byte
containing buffered data , br
*bufio.reader
.
many applications use *bufio.reader
io.reader
after calling readline
, related methods. there's no need buffered data in these applications. reader continue reading buffered data needed.