(buf []byte)
| 160 | } |
| 161 | |
| 162 | func (w *errorWriter) Write(buf []byte) (int, error) { |
| 163 | w.writeCount++ |
| 164 | if (w.bufString != "" && string(buf) == w.bufString) || (w.ErrThreshold > 0 && w.writeCount >= w.ErrThreshold) { |
| 165 | return 0, errors.New(`write error`) |
| 166 | } |
| 167 | if w.ResponseRecorder == nil { |
| 168 | w.ResponseRecorder = httptest.NewRecorder() |
| 169 | } |
| 170 | return w.ResponseRecorder.Write(buf) |
| 171 | } |
| 172 | |
| 173 | func (w *errorWriter) reset() { |
| 174 | w.writeCount = 0 |