From da48f4dfd32a731682bb6ad8f23bf072b33faf12 Mon Sep 17 00:00:00 2001 From: suntala Date: Thu, 13 Mar 2025 18:02:46 +0100 Subject: [PATCH] Use ReplaceAll, TrimSuffix in log --- src/testing/testing.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/testing/testing.go b/src/testing/testing.go index 97336608a4..9172b35238 100644 --- a/src/testing/testing.go +++ b/src/testing/testing.go @@ -1009,12 +1009,11 @@ func (c *common) FailNow() { // indentation and the final newline if necessary. It prefixes the string // with the file and line of the call site. func (c *common) log(s string) { - if n := len(s); n > 0 && (string(s[n-1]) == "\n") { - s = s[:n-1] - } + s = strings.TrimSuffix(s, "\n") + // Second and subsequent lines are indented 4 spaces. This is in addition to // the indentation provided by outputWriter. - s = strings.Replace(s, "\n", fmt.Sprintf("\n%s", indent), -1) + s = strings.ReplaceAll(s, "\n", fmt.Sprintf("\n%s", indent)) s += "\n" // Prefix with the call site. It is located by skipping 3 functions: