Update code sample for Go 1+
`time.LocalTime()` no longer exists. I've updated that line to the current syntax.
This commit is contained in:
@@ -60,8 +60,7 @@ Go uses the `SetCookie` function in the `net/http` package to set cookies:
|
|||||||
|
|
||||||
Here is an example of setting a cookie:
|
Here is an example of setting a cookie:
|
||||||
|
|
||||||
expiration := *time.LocalTime()
|
expiration := time.Now().Add(365 * 24 * time.Hour)
|
||||||
expiration.Year += 1
|
|
||||||
cookie := http.Cookie{Name: "username", Value: "astaxie", Expires: expiration}
|
cookie := http.Cookie{Name: "username", Value: "astaxie", Expires: expiration}
|
||||||
http.SetCookie(w, &cookie)
|
http.SetCookie(w, &cookie)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user