# http：ResponseWriter 未实现 http.Flusher

- **ID:** `go/net-http-flusher-not-available`
- **领域:** go
- **类别:** type_error
- **验证级别:** ai_generated
- **修复率:** 85%

## 根因

在包装或替换原始对象的 ResponseWriter 上使用 http.Flusher，例如使用未保留 Flusher 接口的自定义中间件时。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| Go 1.15 | active | — | — |
| Go 1.16 | active | — | — |
| Go 1.17 | active | — | — |
| Go 1.18 | active | — | — |
| Go 1.19 | active | — | — |
| Go 1.20 | active | — | — |
| Go 1.21 | active | — | — |
| Go 1.22 | active | — | — |
| Go 1.23 | active | — | — |

## 解决方案

1. ```
   Implement Flusher interface in your custom ResponseWriter wrapper by embedding the original writer and forwarding Flush()
   ```
2. ```
   Use http.ResponseController from Go 1.20+ to enable flush without direct Flusher assertion
   ```
3. ```
   Avoid wrapping ResponseWriter if possible; modify the handler to flush via the original writer before wrapping
   ```

## 无效尝试

- **** — The assertion fails because the wrapper replaces the original writer; you must assert on the wrapper. (85% 失败率)
- **** — The original writer supports Flusher, but the wrapper doesn't pass it through; pre-check doesn't help. (70% 失败率)
- **** — Flushing is critical for streaming responses; ignoring it breaks functionality like SSE or chunked transfer. (90% 失败率)
