code: func validatePUBLISHBytes(fixedHeader FixedHeader, remaining []byte) error {
  	// Extract the MQTT Control Packet type.
  	ptype, err := fixedHeader.ptype()
  	if err != nil {
  		return err
  	}
  
  	// Check the length of the fixed header.
  	if len(fixedHeader) < minLenPUBLISHFixedHeader {
  		return ErrInvalidFixedHeaderLen
  	}
  
  	// Check the MQTT Control Packet type.
  	if ptype != TypePUBLISH {
  		return ErrInvalidPacketType
  	}
  
  	// Get the QoS.
  	qos := (fixedHeader[0] & 0x06) >> 1
  
  	// Check the QoS.
  	if !mqtt.ValidQoS(qos) {
  		return ErrInvalidQoS
  	}
  
  	// Check the length of the remaining.
  	if l := len(remaining); l < minLenPUBLISHVariableHeader || l > maxRemainingLength {
  		return ErrInvalidRemainingLen
  	}
  
  	// Extract the length of the Topic Name.
  	lenTopicName, _ := decodeUint16(remaining[0:2])
  
  	// Calculate the length of the variable header.
  	var lenVariableHeader int
  
  	if qos == mqtt.QoS0 {
  		lenVariableHeader = 2 + int(lenTopicName)
  	} else {
  		lenVariableHeader = 2 + int(lenTopicName) + 2
  	}
  
  	// Check the length of the remaining.
  	if len(remaining) < lenVariableHeader {
  		return ErrInvalidRemainingLength
  	}
  
  	// End the validation if the QoS equals to QoS 0.
  	if qos == mqtt.QoS0 {
  		return nil
  	}
  
  	// Extract the Packet Identifier.
  	packetID, _ := decodeUint16(remaining[2+int(lenTopicName) : 2+int(lenTopicName)+2])
  
  	// Check the Packet Identifier.
  	if packetID == 0 {
  		return ErrInvalidPacketID
  	}
  
  	return nil
  }
docs: // validatePUBLISHBytes validates the fixed header and the variable header.