Refine WriteToTempFile docstring

Clarify the documentation for WriteToTempFile to better explain its functionality, ensure consistency, and detail its return values.
This commit is contained in:
Winni Neessen 2024-10-06 16:21:37 +02:00
parent 3333c784a6
commit 0b105048e6
Signed by: wneessen
GPG key ID: 385AC9889632126E
2 changed files with 16 additions and 4 deletions

View file

@ -12,8 +12,14 @@ import (
"os" "os"
) )
// WriteToTempFile will create a temporary file and output the Msg to this file // WriteToTempFile creates a temporary file and writes the Msg content to this file.
// The method will return the filename of the temporary file //
// This method generates a temporary file with a ".eml" extension, writes the Msg to it, and returns the
// filename of the created temporary file.
//
// Returns:
// - A string representing the filename of the temporary file.
// - An error if the file creation or writing process fails.
func (m *Msg) WriteToTempFile() (string, error) { func (m *Msg) WriteToTempFile() (string, error) {
f, err := os.CreateTemp("", "go-mail_*.eml") f, err := os.CreateTemp("", "go-mail_*.eml")
if err != nil { if err != nil {

View file

@ -12,8 +12,14 @@ import (
"io/ioutil" "io/ioutil"
) )
// WriteToTempFile will create a temporary file and output the Msg to this file // WriteToTempFile creates a temporary file and writes the Msg content to this file.
// The method will return the filename of the temporary file //
// This method generates a temporary file with a ".eml" extension, writes the Msg to it, and returns the
// filename of the created temporary file.
//
// Returns:
// - A string representing the filename of the temporary file.
// - An error if the file creation or writing process fails.
func (m *Msg) WriteToTempFile() (string, error) { func (m *Msg) WriteToTempFile() (string, error) {
f, err := ioutil.TempFile("", "go-mail_*.eml") f, err := ioutil.TempFile("", "go-mail_*.eml")
if err != nil { if err != nil {