Goのnet/httpパッケージでCookieを設定しようとしています。私は持っています:
package main
import "io"
import "net/http"
import "time"
func indexHandler(w http.ResponseWriter, req *http.Request) {
expire := time.Now().AddDate(0, 0, 1)
cookie := http.Cookie{"test", "tcookie", "/", "www.domain.com", expire, expire.Format(time.UnixDate), 86400, true, true, "test=tcookie", []string{"test=tcookie"}}
req.AddCookie(&cookie)
io.WriteString(w, "Hello world!")
}
func main() {
http.HandleFunc("/", indexHandler)
http.ListenAndServe(":80", nil)
}
「cookies」で「Golang」をグーグルで検索してみましたが、良い結果が得られませんでした。誰かが私を正しい方向に向けることができれば、それは大いにありがたいです。