title: Retrieving gobs written to file by appending several times
body: <p>I am trying to use encoding/gob to store data to a file and load it later. I want to be able to append new data to the file and load all saved data later, e.g. after restarting my application. While storing to the file using Encode() there are no problems, but when reading it seems I always get only the item which was first stored, not the succinctly stored items.</p>
  
  <p>Here is a minimal example: <a href="https://play.golang.org/p/patGkKDLhM" rel="nofollow noreferrer">https://play.golang.org/p/patGkKDLhM</a></p>
  
  <p>As you see, it works to write two times to an encoder and then read it back. But when closing the file and reopening it again in append mode, writing seems to work, but reading works only for the first two elements (which have been written previously). The two newly added structs cannot be retrieved, I get the error:</p>
  
  <blockquote>
    <p>panic: extra data in buffer</p>
  </blockquote>
  
  <p>I am aware of <a href="https://stackoverflow.com/questions/30927993/append-to-golang-gob-in-a-file-on-disk">Append to golang gob in a file on disk</a> and I also read <a href="https://groups.google.com/forum/#!topic/golang-nuts/bn6vjC5Abd8" rel="nofollow noreferrer">https://groups.google.com/forum/#!topic/golang-nuts/bn6vjC5Abd8</a> </p>
  
  <p>Finally, I also found <a href="https://gist.github.com/kjk/8015952" rel="nofollow noreferrer">https://gist.github.com/kjk/8015952</a> which seems to demonstrate that what I am trying to do does not work. Why? What does this error mean?</p>