On Sun, Dec 15, 2019 at 7:56 PM <smogg...@gmail.com> wrote: > > I'm having a similar problem as the original poster. I expect Buffered() to > return the number of bytes that can be read from the current buffer, like the > documentation states. However a call to Buffered() returns 0 both before and > after a call to any Read() that finds bytes in the buffer. In my case the > Reader is a net.Conn. > > How do we use Buffered() properly? This is the only google result I could > find that even mentions using the function. > > I ended up solving my problem without using bufio.
Note that you are replying to an e-mail from over nine years ago. The Buffered method is fairly special purpose. It just tells you how many bytes you can Read without causing a call to the underlying Reader. What are you really trying to do? Can you show us some code that does not work as you expect? Ian > On Tuesday, August 24, 2010 at 6:21:20 PM UTC-4, Evan Shaw wrote: >> >> On Tue, Aug 24, 2010 at 5:17 PM, Archos <rau...@sent.com> wrote: >> > Well, the doc. *on this case* didn't help me much: >> > >> > "Buffered returns the number of bytes that can be read from the >> > current buffer."[1] >> >> I find that to be a pretty clear description. Consider that it could >> be impossible or at least expensive to find the number of bytes in the >> underlying io.Reader when all you have to go off of is the Read >> method. How would you propose to do it with this type, for example: >> >> type nullReader struct{} >> >> func (r *nullReader) Read(p []byte) (int, os.Error) { >> for i := range p { >> p[i] = 0 >> } >> return len(p), nil >> } >> >> - Evan > > -- > You received this message because you are subscribed to the Google Groups > "golang-nuts" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to golang-nuts+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/golang-nuts/3a062f9c-27ab-4065-bd86-fa4e189acc9b%40googlegroups.com. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CAOyqgcWwSdH%2BGfUHekV%3DEQ%3DpmqtggpHkpeJWdKp3mpyDnib%3DSg%40mail.gmail.com.