-
Notifications
You must be signed in to change notification settings - Fork 375
Added _ = to indicate there is a return from Save #197
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added _ = to indicate there is a return from Save #197
Conversation
This is because I copied the sample and failed to notice there was a return, which for me was failing, and lost a bunch of time to troubleshooting.
Indicated the need for error handling so developer who copy samples get the indication that error handling is required. ( I was learning/tinkering and copied a sample without error handling, failed to notice that Save returns an error in the documentation, and it took me a lot of time/troubleshooting to track down the problem.)
Used _ = in the README.md (so as not to clutter / obscure the message) and "error =" & "if error != nil" in the docs.go to be more explicit. |
This issue has been automatically marked as stale because it hasn't seen a recent update. It'll be automatically closed in a few days. |
README.md
Outdated
@@ -41,7 +41,7 @@ Let's start with an example that shows the sessions API in a nutshell: | |||
session.Values["foo"] = "bar" | |||
session.Values[42] = 43 | |||
// Save it before we write to the response/return from the handler. | |||
session.Save(r, w) | |||
_ = session.Save(r, w) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Handle the error - e.g. if the session save fails, log it.
@elithrar Thanks for the feedback/change request. I was attempting to be consistent with the use of "_" in error handling a few lines above, but I've made a change to match your change request. I didn't log so much as return the HTTP internal error, as I found in other places in the Gorilla Sessions documentation. If you want just logging instead I can do that. |
Thanks! |
This is because I copied the sample and failed to notice there was a return, which for me was failing, and lost a bunch of time to troubleshooting. (Note: I actually copied the samples from here - https://www.gorillatoolkit.org/pkg/sessions - but don't know how to update that page.)
Fixes #
Summary of Changes