code: func (w *Writer) Write(p []byte) (n int, err error) {
  	// Even empty p may make a sense.
  	w.dirty = true
  
  	var nn int
  	for len(p) > w.Available() && w.err == nil {
  		if w.Buffered() == 0 {
  			// Large write, empty buffer. Write directly from p to avoid copy.
  			// Trade off here is that we make additional Write() to underlying
  			// io.Writer when writing frame header.
  			//
  			// On large buffers additional write is better than copying.
  			nn, _ = w.WriteThrough(p)
  		} else {
  			nn = copy(w.buf[w.n:], p)
  			w.n += nn
  			w.FlushFragment()
  		}
  		n += nn
  		p = p[nn:]
  	}
  	if w.err != nil {
  		return n, w.err
  	}
  	nn = copy(w.buf[w.n:], p)
  	w.n += nn
  	n += nn
  
  	// Even if w.Available() == 0 we will not flush buffer preventively because
  	// this could bring unwanted fragmentation. That is, user could create
  	// buffer with size that fits exactly all further Write() call, and then
  	// call Flush(), excepting that single and not fragmented frame will be
  	// sent. With preemtive flush this case will produce two frames – last one
  	// will be empty and just to set fin = true.
  
  	return n, w.err
  }
docs: // Write implements io.Writer.
  //
  // Note that even if the Writer was created to have N-sized buffer, Write()
  // with payload of N bytes will not fit into that buffer. Writer reserves some
  // space to fit WebSocket header data.