MCPcopy Index your code
hub / github.com/expr-lang/expr / indentMessageLines

Function indentMessageLines

internal/testify/assert/assertions.go:305–318  ·  view source on GitHub ↗

Aligns the provided message so that all lines after the first line start at the same location as the first line. Assumes that the first line starts at the correct location (after carriage return, tab, label, spacer and tab). The longestLabelLen parameter specifies the length of the longest label in

(message string, longestLabelLen int)

Source from the content-addressed store, hash-verified

303// The longestLabelLen parameter specifies the length of the longest label in the output (required because this is the
304// basis on which the alignment occurs).
305func indentMessageLines(message string, longestLabelLen int) string {
306 outBuf := new(bytes.Buffer)
307
308 for i, scanner := 0, bufio.NewScanner(strings.NewReader(message)); scanner.Scan(); i++ {
309 // no need to align first line because it starts at the correct location (after the label)
310 if i != 0 {
311 // append alignLen+1 spaces to align with "{{longestLabel}}:" before adding tab
312 outBuf.WriteString("\n\t" + strings.Repeat(" ", longestLabelLen+1) + "\t")
313 }
314 outBuf.WriteString(scanner.Text())
315 }
316
317 return outBuf.String()
318}
319
320type failNower interface {
321 FailNow()

Callers 1

labeledOutputFunction · 0.85

Calls 1

StringMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…