fix(template): use TrimSuffix instead of TrimRight to avoid over-stripping

TrimRight strips all trailing newlines which could affect templates
that intentionally end without a trailing newline (see #31948).
TrimSuffix removes at most one trailing newline, which is sufficient
to fix the double-newline regression from #32163.

Co-authored-by: Cloud-Architect-Emma <Cloud-Architect-Emma@users.noreply.github.com>
Signed-off-by: Cloud-Architect-Emma <your@email.com>
pull/32170/head
Cloud-Architect-Emma 1 month ago
parent efb2e0984f
commit b9b535c218

@ -732,7 +732,7 @@ func writeToFile(outputDir string, name string, data string, appendData bool) er
defer f.Close()
_, err = fmt.Fprintf(f, "---\n# Source: %s\n%s\n", name, strings.TrimRight(data, "\n"))
_, err = fmt.Fprintf(f, "---\n# Source: %s\n%s\n", name, strings.TrimSuffix(data, "\n"))
if err != nil {
return err

Loading…
Cancel
Save