Use ReplaceAll, TrimSuffix in log

This commit is contained in:
suntala 2025-03-13 18:02:46 +01:00
parent 010277f588
commit da48f4dfd3
1 changed files with 3 additions and 4 deletions

View File

@ -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: