MCPcopy Create free account
hub / github.com/cockroachdb/redact / SafeFormat

Method SafeFormat

builder/builder.go:39–55  ·  view source on GitHub ↗

SafeFormat implements SafeFormatter.

(p i.SafePrinter, _ rune)

Source from the content-addressed store, hash-verified

37
38// SafeFormat implements SafeFormatter.
39func (b StringBuilder) SafeFormat(p i.SafePrinter, _ rune) {
40 // We only support the %v / %s natural print here.
41 // Go supports other formatting verbs for strings: %x/%X/%q.
42 //
43 // We don't do this here, keeping in mind that the output
44 // of a SafeFormat must remain a redactable string.
45 //
46 // %x/%X cannot be implemented because they would turn redaction
47 // markers into hex codes, and the entire result string would
48 // appear safe for reporting, which would break the semantics
49 // of this package.
50 //
51 // %q cannot be implemented because it replaces non-ASCII characters
52 // with numeric unicode escapes, which breaks redaction
53 // markers too.
54 p.Print(b.RedactableString())
55}
56
57var _ i.SafeFormatter = StringBuilder{}
58var _ i.SafeFormatter = (*StringBuilder)(nil)

Callers

nothing calls this directly

Calls 2

RedactableStringMethod · 0.80
PrintMethod · 0.65

Tested by

no test coverage detected