(p []byte)
| 136 | } |
| 137 | |
| 138 | func (w *redactingWriter) Write(p []byte) (int, error) { |
| 139 | r := loadRedactor() |
| 140 | if r == nil { |
| 141 | return w.inner.Write(p) |
| 142 | } |
| 143 | // RedactEncoded is byte-length-preserving (Redact substitutes within |
| 144 | // the same character class), so the redacted slice has len(p). We |
| 145 | // transform p, hand the result to the sink, and report success in |
| 146 | // terms of p — the io.Writer contract is "wrote n bytes from p"; the |
| 147 | // transformation is invisible to the caller. On error, return 0 so |
| 148 | // the caller can retry the original p without trying to reason about |
| 149 | // partial writes of redacted text. |
| 150 | if _, err := w.inner.Write([]byte(r.RedactEncoded(string(p)))); err != nil { |
| 151 | return 0, err |
| 152 | } |
| 153 | return len(p), nil |
| 154 | } |
| 155 | |
| 156 | func (w *redactingWriter) Sync() error { |
| 157 | return w.inner.Sync() |
nothing calls this directly
no test coverage detected