Standard library / net/http

http.ErrNoCookie

Sentinel returned by Request.Cookie when no named cookie is present. Expected stdout: 'true\n'.

Formal Syntax & Structure

go syntaxgo
var ErrNoCookie error

Working Example

Example Snippetgo
package main
import (  "errors"  "fmt"  "net/http")
func main() {  r := must(http.NewRequest("GET", "http://example.invalid", nil))  _, e := r.Cookie("missing")  fmt.Println(errors.Is(e, http.ErrNoCookie))}
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