code: func (stream *Stream) Write(p []byte) (nn int, err error) {
  	stream.buf = append(stream.buf, p...)
  	if stream.out != nil {
  		nn, err = stream.out.Write(stream.buf)
  		stream.buf = stream.buf[nn:]
  		return
  	}
  	return len(p), nil
  }
docs: // Write writes the contents of p into the buffer.
  // It returns the number of bytes written.
  // If nn < len(p), it also returns an error explaining
  // why the write is short.