From 4971155ddd8722b29b83719e9fac5883ab726aed Mon Sep 17 00:00:00 2001 From: PratikDhanave Date: Wed, 16 Sep 2026 13:13:43 +0530 Subject: [PATCH] Fix DataContent.SaveToFile godoc for the empty-Name and explicit-path cases The comment said 'otherwise a random name and inferred extension are used', but the random-name behavior actually applies in the empty-path/existing-directory case when Name is empty; when path names a specific (non-existent) file the content is written to that path verbatim. Corrected the description. --- message/datacontent.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/message/datacontent.go b/message/datacontent.go index 367af7bf..a40206dd 100644 --- a/message/datacontent.go +++ b/message/datacontent.go @@ -63,9 +63,10 @@ func NewDataContentFromReader(reader io.Reader, mediaType string) (*DataContent, } // SaveToFile writes the decoded content to path without overwriting an -// existing file. If path is empty or names an existing directory, Name is used -// as the file name; otherwise a random name and inferred extension are used. -// The returned path identifies the created file. +// existing file. If path is empty or names an existing directory, the file is +// created in that directory using Name, or a random name with an inferred +// extension when Name is empty. Otherwise the content is written to path +// verbatim. The returned path identifies the created file. func (t *DataContent) SaveToFile(path string) (string, error) { if t == nil { return "", fmt.Errorf("content cannot be nil")