func handler(w http.ResponseWriter, r *http.Request) { cookie := http.Cookie{Name: "mycookie", Value: "myvalue"} http.SetCookie(w, &cookie) }
func handler(w http.ResponseWriter, r *http.Request) { cookie, err := r.Cookie("mycookie") if err == nil { fmt.Fprintln(w, "Value of mycookie:", cookie.Value) } }In this example, the `r.Cookie()` function is used to retrieve a cookie with the name "mycookie" from the HTTP request. If the cookie was found, its value is printed to the HTTP response. The `net/http` package is the standard library for HTTP client and server implementations in Go, and includes support for cookies via the `http.Cookie` type.