From f8caa5599b0e3fe322ae7bd26c929b9ad47439cc Mon Sep 17 00:00:00 2001 From: Winni Neessen Date: Sun, 27 Oct 2024 14:55:51 +0100 Subject: [PATCH] Refactor buffer creation in msg.go Replace `bytes.Buffer{}` with `bytes.NewBuffer(nil)` for buffer instantiation to improve clarity and consistency. This change simplifies the buffer creation process and aligns it with common Go practices. --- msg.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/msg.go b/msg.go index 1fd97a4..4a4714d 100644 --- a/msg.go +++ b/msg.go @@ -1712,11 +1712,11 @@ func (m *Msg) SetBodyTextTemplate(tpl *tt.Template, data interface{}, opts ...Pa if tpl == nil { return errors.New(errTplPointerNil) } - buf := bytes.Buffer{} - if err := tpl.Execute(&buf, data); err != nil { + buffer := bytes.NewBuffer(nil) + if err := tpl.Execute(buffer, data); err != nil { return fmt.Errorf(errTplExecuteFailed, err) } - writeFunc := writeFuncFromBuffer(&buf) + writeFunc := writeFuncFromBuffer(buffer) m.SetBodyWriter(TypeTextPlain, writeFunc, opts...) return nil }