Thanks it's perfectly clear now. I actually knew that but it didn't look 
immediately obvious. 

On Monday, August 14, 2017 at 2:51:13 PM UTC+2, Konstantin Khomoutov wrote:
>
> On Mon, Aug 14, 2017 at 05:43:04AM -0700, Doğan Kurt wrote: 
>
> > > Consider combining using the bufio package and scanning form a 
> buffered 
> > > reader using fmt.Fscanf(). 
> > 
> > Great worked like a charm. I just thought i couldn't pass *bufio.Reader 
> to 
> > Fscanf which takes io.Reader. 
>
> Oh, then that's something which you definitely should make yourself 
> accustomed more -- this consept is one of the corner stones of Go. 
>
> Basically, interfaces in Go are sort-of "backwards" to what they mean in 
> other, "more mainstream" languages.  The fact fmt.Fscanf() accepts an 
> io.Reader means it accepts a value of absolulely any type which 
> implements func Read ([]byte) (int, error).  So it would accept, say, a 
> network socket just as fine as a bufio.Reader or bytes.Buffer or any 
> other custom type implementing that method. 
>
> [1] might be a good start. 
>
> 1. https://golang.org/doc/effective_go.html#interfaces_and_types 
>
>

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

Reply via email to