package service import ( "io" "net/http" ) func newWriteFlusher(w http.ResponseWriter) io.Writer { return writeFlusher{w.(interface { io.Writer http.Flusher })} } type writeFlusher struct { wf interface { io.Writer http.Flusher } } func (w writeFlusher) Write(p []byte) (int, error) { defer w.wf.Flush() return w.wf.Write(p) }