Refactor buffer initialization in NewReader.

Replaced bytes.Buffer{} with bytes.NewBuffer(nil) for buffer initialization in NewReader method of Msg. This change enhances clarity and consistency in buffer handling.
This commit is contained in:
Winni Neessen 2024-10-28 17:04:44 +01:00
parent d39953c837
commit a59173fae0
Signed by: wneessen
GPG key ID: 385AC9889632126E

4
msg.go
View file

@ -2371,8 +2371,8 @@ func (m *Msg) WriteToSendmailWithContext(ctx context.Context, sendmailPath strin
// - https://datatracker.ietf.org/doc/html/rfc5322 // - https://datatracker.ietf.org/doc/html/rfc5322
func (m *Msg) NewReader() *Reader { func (m *Msg) NewReader() *Reader {
reader := &Reader{} reader := &Reader{}
buffer := bytes.Buffer{} buffer := bytes.NewBuffer(nil)
_, err := m.Write(&buffer) _, err := m.Write(buffer)
if err != nil { if err != nil {
reader.err = fmt.Errorf("failed to write Msg to Reader buffer: %w", err) reader.err = fmt.Errorf("failed to write Msg to Reader buffer: %w", err)
} }