code: func WriteHeader(w io.Writer, h Header) error {
  	// Make slice of bytes with capacity 14 that could hold any header.
  	//
  	// We use unsafe to stick bts to stack and avoid allocations.
  	//
  	// Using stack based slice is safe here, cause golang docs for io.Writer
  	// says that "Implementations must not retain p".
  	// See https://golang.org/pkg/io/#Writer
  	var b [MaxHeaderSize]byte
  	bp := uintptr(unsafe.Pointer(&b))
  	bh := &reflect.SliceHeader{
  		Data: bp,
  		Len:  MaxHeaderSize,
  		Cap:  MaxHeaderSize,
  	}
  	bts := *(*[]byte)(unsafe.Pointer(bh))
  	_ = bts[MaxHeaderSize-1] // bounds check hint to compiler.
  
  	if h.Fin {
  		bts[0] |= bit0
  	}
  	bts[0] |= h.Rsv << 4
  	bts[0] |= byte(h.OpCode)
  
  	var n int
  	switch {
  	case h.Length <= len7:
  		bts[1] = byte(h.Length)
  		n = 2
  
  	case h.Length <= len16:
  		bts[1] = 126
  		binary.BigEndian.PutUint16(bts[2:4], uint16(h.Length))
  		n = 4
  
  	case h.Length <= len64:
  		bts[1] = 127
  		binary.BigEndian.PutUint64(bts[2:10], uint64(h.Length))
  		n = 10
  
  	default:
  		return ErrHeaderLengthUnexpected
  	}
  
  	if h.Masked {
  		bts[1] |= bit0
  		n += copy(bts[n:], h.Mask[:])
  	}
  
  	_, err := w.Write(bts[:n])
  
  	return err
  }
docs: // WriteHeader writes header binary representation into w.