Standard library / net/http
http.ResponseController.SetWriteDeadline()
Sets an absolute write deadline for the response controller when supported. A zero time clears the deadline. The recorder demonstrates unsupported-operation handling. Expected stdout: 'true\n'.
Formal Syntax & Structure
go syntaxgo
func (c *ResponseController) SetWriteDeadline(deadline time.Time) errorParameters & Attributes
| Name | Type | Description |
|---|---|---|
| deadline | time.Time | Absolute I/O deadline; zero clears it. |
Return Value
error
Operation result; check errors and validity indicators when returned.
Working Example
Example Snippetgo
package main
import ( "errors" "fmt" "net/http" "net/http/httptest" "time")
func main() { e := http.NewResponseController(httptest.NewRecorder()).SetWriteDeadline(time.Time{}) fmt.Println(errors.Is(e, http.ErrNotSupported))}
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) }}