mirror of
https://github.com/wneessen/go-mail.git
synced 2024-11-21 21:30:50 +01:00
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.
This commit is contained in:
parent
35ffc95102
commit
f8caa5599b
1 changed files with 3 additions and 3 deletions
6
msg.go
6
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
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue