code: func (s *Stream) Write(b []byte) (n int, err error) {
  	s.sendLock.Lock()
  	defer s.sendLock.Unlock()
  	total := 0
  	for total < len(b) {
  		n, err := s.write(b[total:])
  		total += n
  		if err != nil {
  			return total, err
  		}
  	}
  	return total, nil
  }
docs: // Write is used to write to the stream