mirror of
https://github.com/wneessen/go-mail.git
synced 2024-11-24 14:40:49 +01:00
Refactor buffer initialization in message template execution
Change buffer initialization from an empty `bytes.Buffer` to `bytes.NewBuffer(nil)` to streamline buffer allocation. This adjustment ensures better flexibility and aligns with best practices in handling buffer slices.
This commit is contained in:
parent
0aa81d724b
commit
432e21f162
1 changed files with 3 additions and 3 deletions
6
msg.go
6
msg.go
|
@ -1681,11 +1681,11 @@ func (m *Msg) SetBodyHTMLTemplate(tpl *ht.Template, data interface{}, opts ...Pa
|
|||
if tpl == nil {
|
||||
return errors.New(errTplPointerNil)
|
||||
}
|
||||
buffer := bytes.Buffer{}
|
||||
if err := tpl.Execute(&buffer, data); err != nil {
|
||||
buffer := bytes.NewBuffer(nil)
|
||||
if err := tpl.Execute(buffer, data); err != nil {
|
||||
return fmt.Errorf(errTplExecuteFailed, err)
|
||||
}
|
||||
writeFunc := writeFuncFromBuffer(&buffer)
|
||||
writeFunc := writeFuncFromBuffer(buffer)
|
||||
m.SetBodyWriter(TypeTextHTML, writeFunc, opts...)
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue