code: func (b *Buffer) WriteTo(w io.Writer) (n int64, err error) {
  	if b.off < len(b.buf) {
  		nBytes := b.Len()
  		m, e := w.Write(b.buf[b.off:])
  		if m > nBytes {
  			panic("leveldb/util.Buffer.WriteTo: invalid Write count")
  		}
  		b.off += m
  		n = int64(m)
  		if e != nil {
  			return n, e
  		}
  		// all bytes should have been written, by definition of
  		// Write method in io.Writer
  		if m != nBytes {
  			return n, io.ErrShortWrite
  		}
  	}
  	// Buffer is now empty; reset.
  	b.Truncate(0)
  	return
  }
docs: // WriteTo writes data to w until the buffer is drained or an error occurs.
  // The return value n is the number of bytes written; it always fits into an
  // int, but it is int64 to match the io.WriterTo interface. Any error
  // encountered during the write is also returned.