bufio.Reader

109 views
Skip to first unread message

WALID BELRHALMIA

unread,
Aug 31, 2015, 1:40:00 PM8/31/15
to golang-nuts
  i didn't understand this documentation  {{{{

    type Reader struct {
        // contains filtered or unexported fields
}
func NewReader(rd io.Reader) *Reader
NewReader returns a new Reader whose buffer has the default size
}}}}  

what is the buffer of a Reader struct how it's implemented

Brad Fitzpatrick

unread,
Aug 31, 2015, 2:02:43 PM8/31/15
to WALID BELRHALMIA, golang-nuts
Click it and see:


The public documentation only shows you the public interface and not the private implementation.


--
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...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Konstantin Khomoutov

unread,
Aug 31, 2015, 3:10:23 PM8/31/15
to WALID BELRHALMIA, golang-nuts
On Mon, 31 Aug 2015 10:39:59 -0700 (PDT)
WALID BELRHALMIA <wbelr...@gmail.com> wrote:

> i didn't understand this documentation {{{{
>
> type Reader struct {
>
> // contains filtered or unexported fields}
>
> func NewReader(rd io <http://golang.org/pkg/io/>.Reader
> <http://golang.org/pkg/io/#Reader>) *Reader
> <http://golang.org/pkg/bufio/#Reader>
>
> NewReader returns a new Reader whose buffer has the default size
>
> }}}}
>
> *what is the buffer of a Reader struct how it's implemented*

To elaborate on Brad's response, you don't necessarily need to have
direct to the fields of variables of a particular type for such
variables to be useful, and bufio.Reader is an example of a type with
no directly accessible fields.

The basic idea is that a variable of type bufio.Reader does only hold
some internal state enabling certain methods, namely Read(), be called
on this variable repeatedly -- making it read its source data
sequentially. You have no business fiddling with this state, and hence
it's not made available to you.
Reply all
Reply to author
Forward
0 new messages