code: func (cli *Client) newPUBLISHPacket(opts *PublishOptions) (packet.Packet, error) {
  	// Define a Packet Identifier.
  	var packetID uint16
  
  	if opts.QoS != mqtt.QoS0 {
  		// Lock for reading and updating the Session.
  		cli.muSess.Lock()
  
  		defer cli.muSess.Unlock()
  
  		// Define an error.
  		var err error
  
  		// Generate a Packet Identifer.
  		if packetID, err = cli.generatePacketID(); err != nil {
  			return nil, err
  		}
  	}
  
  	// Create a PUBLISH Packet.
  	p, err := packet.NewPUBLISH(&packet.PUBLISHOptions{
  		QoS:       opts.QoS,
  		Retain:    opts.Retain,
  		TopicName: opts.TopicName,
  		PacketID:  packetID,
  		Message:   opts.Message,
  	})
  	if err != nil {
  		return nil, err
  	}
  
  	if opts.QoS != mqtt.QoS0 {
  		// Set the Packet to the Session.
  		cli.sess.sendingPackets[packetID] = p
  	}
  
  	// Return the Packet.
  	return p, nil
  }
docs: // newPUBLISHPacket creates and returns a PUBLISH Packet.