title: Golang read from pipe reads tons of data
body: <p>I'm trying to read an archive that's being tarred, streaming, to stdin, but I'm somehow reading <em>far</em> more data in the pipe than tar is sending.</p>
  
  <p>I run my command like this:</p>
  
  <pre><code>tar -cf - somefolder | ./my-go-binary
  </code></pre>
  
  <p>The source code is like this:</p>
  
  <pre><code>package main
  
  import (
      "bufio"
      "io"
      "log"
      "os"
  )
  
  // Read from standard input
  func main() {
      reader := bufio.NewReader(os.Stdin)
      // Read all data from stdin, processing subsequent reads as chunks.
      parts := 0
      for {
          parts++
          data := make([]byte, 4&lt;&lt;20) // Read 4MB at a time
          _, err := reader.Read(data)
          if err == io.EOF {
              break
          } else if err != nil {
              log.Fatalf("Problems reading from input: %s", err)
          }
      }
      log.Printf("Total parts processed: %d\n", parts)
  }
  </code></pre>
  
  <p>For a 100MB tarred folder, I'm getting 1468 chunks of 4MB (that's 6.15GB)! Further, it doesn't seem to matter how large the <code>data []byte</code> array is: if I set the chunk size to 40MB, I still get ~1400 chunks of 40MB data, which makes no sense at all.</p>
  
  <p>Is there something I need to do to read data from <code>os.Stdin</code> properly with Go?</p>