MCPcopy
hub / github.com/nats-io/nats.go / Equal

Method Equal

nats.go:811–839  ·  view source on GitHub ↗

Compares two msgs, ignores sub but checks all other public fields.

(msg *Msg)

Source from the content-addressed store, hash-verified

809
810// Compares two msgs, ignores sub but checks all other public fields.
811func (m *Msg) Equal(msg *Msg) bool {
812 if m == msg {
813 return true
814 }
815 if m == nil || msg == nil {
816 return false
817 }
818 if m.Subject != msg.Subject || m.Reply != msg.Reply {
819 return false
820 }
821 if !bytes.Equal(m.Data, msg.Data) {
822 return false
823 }
824 if len(m.Header) != len(msg.Header) {
825 return false
826 }
827 for k, v := range m.Header {
828 val, ok := msg.Header[k]
829 if !ok || len(v) != len(val) {
830 return false
831 }
832 for i, hdr := range v {
833 if hdr != val[i] {
834 return false
835 }
836 }
837 }
838 return true
839}
840
841// Size returns a message size in bytes.
842func (m *Msg) Size() int {

Callers 15

TestBasicHeadersFunction · 0.95
checkConfigFunction · 0.80
ackReplyMethod · 0.80
TestWSReaderFunction · 0.80
TestWSDecompressorFunction · 0.80
ReadMethod · 0.80
TestClientTLSConfigFunction · 0.80
TestClientCertificateFunction · 0.80

Calls

no outgoing calls

Tested by 15

TestBasicHeadersFunction · 0.76
TestWSReaderFunction · 0.64
TestWSDecompressorFunction · 0.64
TestClientTLSConfigFunction · 0.64
TestClientCertificateFunction · 0.64
TestWSBasicFunction · 0.64
TestWSCompressionFunction · 0.64