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: