Standard library / net/http/cookiejar

cookiejar.New()

Construct an in-memory cookie jar. A nil PublicSuffixList is suitable only for isolated tests; use a maintained public suffix list in production. Expected stdout: 'true\n'.

Formal Syntax & Structure

go syntaxgo
func New(o *Options) (*Jar, error)

Parameters & Attributes

NameTypeDescription
o*OptionsOptional cookie jar configuration.

Return Value

(*Jar, error)

Operation result; check errors and validity indicators when returned.

Working Example

Example Snippetgo
package main
import (  "fmt"  "net/http/cookiejar")
func main() { j := must(cookiejar.New(nil)); fmt.Println(j != 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)  }}
Go Reference