Standard library / net/http/httptest

httptest.ResponseRecorder.Flush()

Records a flush call and commits an implicit 200 status when necessary. Expected stdout: 'true 200\n'.

Formal Syntax & Structure

go syntaxgo
func (rw *ResponseRecorder) Flush()

Working Example

Example Snippetgo
package main
import (  "fmt"  "net/http/httptest")
func main() { w := httptest.NewRecorder(); w.Flush(); fmt.Println(w.Flushed, w.Result().StatusCode) }
func must[T any](v T, e error) T {  if e != nil {    panic(e)  }  return v}func check(e error) {  if e != nil {    panic(e)  }}
Go Reference