title: What is the difference between Pointer and Value receiver types?
body: <p>I was writing a program that reads data from a io.Reader and caches them in a bytes.Buffer.</p>
  
  <pre><code>type SecureReader struct {
      pipe      io.Reader
      shared    *[32]byte
      decrypted bytes.Buffer
  }
  
  func (s SecureReader) Read(b []byte) (int, error) {
      s.decryptPipeIntoBuffer()
      return s.decrypted.Read(b)
  }
  
  func (s SecureReader) decryptPipeIntoBuffer() (int, error) {/*Lots of code...*/}
  </code></pre>
  
  <p>I first used a value receiver, because I thought they were the same. However, I noticed my method does not do anything when invoked: SecureReader.Read() would always return io.EOF.</p>
  
  <p>I banged my head around and changed the receiver type to</p>
  
  <pre><code>func (s *SecureReader) decryptPipeIntoBuffer() (int, error) {/*Lots of code...*/}
  </code></pre>
  
  <p>Now my code magically works. What is going on?</p>