title: Implementing Reader interface
body: <p>I understand the general concept of Go's interfaces. However, I was recently looking into implementing the <code>io.Reader</code> interface, and it has me confused. I found this post which didn't help to much.</p>
  
  <p><a href="https://stackoverflow.com/questions/25526790/reader-interface-and-the-read-method-in-golang">Reader interface and the Read method in golang</a></p>
  
  <p>To start with, the accepted answer is using <code>io.Reader</code>'s <code>Read</code> function, which as far as I can tell is never implemented. Second, how does the <code>Read</code> function work in the context of something like <code>ioutil.ReadAll</code>. It takes something that implemented the <code>io.Reader</code> interface and returns a slice of bytes. I don't understand how something that is returning only an <code>int</code> and <code>err</code> can be processed into a slice of bytes.</p>
  
  <p>Edit:</p>
  
  <p>I was helped in the go-nuts IRC channel and this was the provided answer as to how you would likely actually implement one <a href="http://play.golang.org/p/ejpUVOx8jR" rel="noreferrer">http://play.golang.org/p/ejpUVOx8jR</a>. Much thanks to the go community.</p>
  
  <p>Edit 2:</p>
  
  <p>as pointed out below the implementation above will fail in the case where the strign is larger than the buffer. This is a more sane implementation <a href="http://play.golang.org/p/t4Zg8TnF33" rel="noreferrer">http://play.golang.org/p/t4Zg8TnF33</a>.</p>