code: func NewPUBLISHFromBytes(fixedHeader FixedHeader, remaining []byte) (Packet, error) {
  	// Validate the byte data.
  	if err := validatePUBLISHBytes(fixedHeader, remaining); err != nil {
  		return nil, err
  	}
  
  	// Get the first byte from the fixedHeader.
  	b := fixedHeader[0]
  
  	// Create a PUBLISH Packet.
  	p := &PUBLISH{
  		DUP:    b&0x08 == 0x08,
  		QoS:    b & 0x06 >> 1,
  		retain: b&0x01 == 0x01,
  	}
  
  	// Set the fixed header to the Packet.
  	p.fixedHeader = fixedHeader
  
  	// Extract the length of the Topic Name.
  	lenTopicName, _ := decodeUint16(remaining[0:2])
  
  	// Calculate the length of the variable header.
  	var lenVariableHeader int
  
  	if p.QoS == mqtt.QoS0 {
  		lenVariableHeader = 2 + int(lenTopicName)
  	} else {
  		lenVariableHeader = 2 + int(lenTopicName) + 2
  	}
  
  	// Set the variable header to the Packet.
  	p.variableHeader = remaining[:lenVariableHeader]
  
  	// Set the payload to the Packet.
  	p.payload = remaining[lenVariableHeader:]
  
  	// Set the Topic Name to the Packet.
  	p.TopicName = remaining[2 : 2+lenTopicName]
  
  	// Extract the Packet Identifier.
  	var packetID uint16
  
  	if p.QoS != mqtt.QoS0 {
  		packetID, _ = decodeUint16(remaining[2+lenTopicName : 2+lenTopicName+2])
  	}
  
  	// Set the Packet Identifier to the Packet.
  	p.PacketID = packetID
  
  	// Set the Application Message to the Packet.
  	p.Message = p.payload
  
  	// Return the Packet.
  	return p, nil
  }
docs: // NewPUBLISHFromBytes creates the PUBLISH Packet
  // from the byte data and returns it.