String returns the message as a string.
()
| 70 | |
| 71 | // String returns the message as a string. |
| 72 | func (m *Message) String() string { |
| 73 | sb := strings.Builder{} |
| 74 | |
| 75 | if m.Event != "" { |
| 76 | sb.WriteString(fmt.Sprintf("event: %s\n", m.Event)) |
| 77 | } |
| 78 | sb.WriteString(fmt.Sprintf("data: %v\n\n", m.Data)) |
| 79 | |
| 80 | return sb.String() |
| 81 | } |
| 82 | |
| 83 | // WithEvent sets the event name for the message. |
| 84 | func (m *Message) WithEvent(event string) Envelope { |