Standard library / net/http
http.ErrServerClosed
Returned by server serving methods after Shutdown or Close. Treat it as expected during intentional shutdown. Expected stdout: 'true\n'.
Formal Syntax & Structure
go syntaxgo
var ErrServerClosed = errors.New("http: Server closed")Working Example
Example Snippetgo
package main
import ( "errors" "fmt" "net/http")
func main() { s := &http.Server{} check(s.Close()) fmt.Println(errors.Is(s.ListenAndServe(), http.ErrServerClosed))}
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) }}