Standard library / net/http
http.CloseNotifier
Deprecated optional interface for notification of a closed client connection; prefer Request.Context. The recorder lacks this interface. Expected stdout: 'false\n'.
Formal Syntax & Structure
go syntaxgo
type CloseNotifier interface { CloseNotify() <-chan bool}Working Example
Example Snippetgo
package main
import ( "fmt" "net/http" "net/http/httptest")
func main() { var w http.ResponseWriter = httptest.NewRecorder() _, ok := w.(http.CloseNotifier) fmt.Println(ok)}
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) }}