endRedactable adds the closing redaction marker.
()
| 195 | |
| 196 | // endRedactable adds the closing redaction marker. |
| 197 | func (b *Buffer) endRedactable() { |
| 198 | if len(b.buf) == 0 { |
| 199 | return |
| 200 | } |
| 201 | if bytes.HasSuffix(b.buf, m.StartBytes) { |
| 202 | // Special case: remove a trailing open marker and call it a day. |
| 203 | b.buf = b.buf[:len(b.buf)-m.StartLen] |
| 204 | } else { |
| 205 | p, ok := b.tryGrowByReslice(m.EndLen) |
| 206 | if !ok { |
| 207 | p = b.grow(m.EndLen) |
| 208 | } |
| 209 | copy(b.buf[p:], m.EndS) |
| 210 | } |
| 211 | b.markerOpen = false |
| 212 | } |
| 213 | |
| 214 | func (b *Buffer) startWrite() { |
| 215 | if b.mode == UnsafeEscaped && !b.markerOpen { |
no test coverage detected