code: func readToEOF(r io.Reader, buf []byte) (n int, err error) {
  	for err == nil && n < len(buf) {
  		var nn int
  		nn, err = r.Read(buf[n:])
  		n += nn
  	}
  	switch {
  	case err == io.EOF:
  		return n, nil
  	case n == MaxBlockSize && err == nil:
  		// This is paranoic, but some readers will return
  		// quickly when passed a zero-length byte slice.
  		var dummy [1]byte
  		_, err = r.Read(dummy[:])
  		if err == nil {
  			return n, io.ErrShortBuffer
  		}
  		if err == io.EOF {
  			err = nil
  		}
  	}
  	return n, err
  }
docs: // readToEOF will exhaust r or fill buf.
  // If r does not EOF upon reading up to len(buf) bytes then readToEOF will return
  // io.ErrShortBuffer and an additional byte will be discarded from the reader.