-// WriteTo writes the entire contents of this.Reader to dest. Returns
-// BadChecksum if the checksum doesn't match.
-func (this HashCheckingReader) WriteTo(dest io.Writer) (written int64, err error) {
- if writeto, ok := this.Reader.(io.WriterTo); ok {
- written, err = writeto.WriteTo(io.MultiWriter(dest, this.Hash))
- } else {
- written, err = io.Copy(io.MultiWriter(dest, this.Hash), this.Reader)
+// WriteTo writes the entire contents of hcr.Reader to dest. Returns
+// BadChecksum if writing is successful but the checksum doesn't
+// match.
+func (hcr HashCheckingReader) WriteTo(dest io.Writer) (written int64, err error) {
+ written, err = io.Copy(io.MultiWriter(dest, hcr.Hash), hcr.Reader)
+ if err != nil {
+ return written, err