title: Golang unexpected EOF
body: <p>Here's my code, I'm new to Go.
  I tried googling the issue, but I can't quite put my finger on it.
  I think it has something to do with the <code>Read()</code> method.</p>
  
  <pre><code>package main
  
  import (
      ...
  )
  
  type compressor struct {
      content []byte
  }
  
  func (r *compressor) compress() []byte {
      ...
  }
  
  func (r *compressor) decompress() []byte {
      var buffer bytes.Buffer
      dc := flate.NewReader(&amp;buffer)
      _, err := dc.Read(r.content)
      if err != nil {
          if err != io.EOF {
              log.Fatal(err)
          }
      }
  
      return buffer.Bytes()
  }
  
  func main() {
      fileName := os.Args[1]
      fmt.Println(os.Args)
      contents, err := ioutil.ReadFile(fileName)
      if err != nil {
          log.Fatal(err)
      }
  
      fmt.Print("Uncompressed data: ")
      fmt.Println(len(contents))
  
      comp := compressor{contents}
      buffer := comp.decompress()
      fmt.Print("Uncompressed data: ")
      fmt.Println(len(comp.decompress()))
  
      err = ioutil.WriteFile(fileName+".decjc", buffer, 0644)
      if err != nil {
          log.Fatal(err)
      }
  }
  </code></pre>
  
  <p>Here's the output</p>
  
  <blockquote>
  <pre><code>dylan@skynet:~/Documents/EXP/jc$ ./jc data.txt.jc 
  [./jc data.txt.jc]
  Uncompressed data: 2364480
  2018/06/29 21:41:35 unexpected EOF
  </code></pre>
  </blockquote>