code: func NewPUBLISH(opts *PUBLISHOptions) (Packet, error) {
  	// Initialize the options.
  	if opts == nil {
  		opts = &PUBLISHOptions{}
  	}
  
  	// Validate the options.
  	if err := opts.validate(); err != nil {
  		return nil, err
  	}
  
  	// Create a PUBLISH Packet.
  	p := &PUBLISH{
  		DUP:       opts.DUP,
  		QoS:       opts.QoS,
  		retain:    opts.Retain,
  		TopicName: opts.TopicName,
  		PacketID:  opts.PacketID,
  		Message:   opts.Message,
  	}
  
  	// Set the variable header to the Packet.
  	p.setVariableHeader()
  
  	// Set the payload to the Packet.
  	p.setPayload()
  
  	// Set the Fixed header to the Packet.
  	p.setFixedHeader()
  
  	// Return the Packet.
  	return p, nil
  }
docs: // NewPUBLISH creates and returns a PUBLISH Packet.