Standard library / net/http
http.Cookie.Valid()
Check structural cookie validity; does not establish browser acceptance or domain authorization. Expected stdout: 'true\n'.
Formal Syntax & Structure
go syntaxgo
func (c *Cookie) Valid() errorReturn Value
error
Operation result; check errors and validity indicators when returned.
Working Example
Example Snippetgo
package main
import ( "fmt" "net/http")
func main() { c := http.Cookie{Name: "bad name", Value: "yes"}; fmt.Println(c.Valid() != nil) }
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) }}