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

Method SetMode

internal/buffer/buffer.go:259–272  ·  view source on GitHub ↗

SetMode changes the output mode.

(newMode OutputMode)

Source from the content-addressed store, hash-verified

257
258// SetMode changes the output mode.
259func (b *Buffer) SetMode(newMode OutputMode) {
260 if b.mode == newMode {
261 // noop
262 return
263 }
264 if b.mode == UnsafeEscaped || b.mode == SafeEscaped {
265 b.escapeToEnd(b.mode == UnsafeEscaped /* breakNewLines */)
266 }
267 if b.markerOpen {
268 b.endRedactable()
269 }
270 b.validUntil = len(b.buf)
271 b.mode = newMode
272}
273
274// Reset resets the buffer to be empty,
275// but it retains the underlying storage for use by future writes.

Callers 15

TestBufferUnsafeWritesFunction · 0.95
resetWithModeMethod · 0.95
TestBufferRawSafeWritesFunction · 0.95
Example_newlinesFunction · 0.95
Example_mixed_writesFunction · 0.95
PrintMethod · 0.80
PrintfMethod · 0.80
startUnsafeMethod · 0.80
startPreRedactableMethod · 0.80

Calls 2

escapeToEndMethod · 0.95
endRedactableMethod · 0.95

Tested by 8

TestBufferUnsafeWritesFunction · 0.76
resetWithModeMethod · 0.76
TestBufferRawSafeWritesFunction · 0.76
Example_newlinesFunction · 0.76
Example_mixed_writesFunction · 0.76