Skip to content

add defer res.Close() documentation #182

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

Closed
wants to merge 1 commit into from
Closed

add defer res.Close() documentation #182

wants to merge 1 commit into from

Conversation

bryfry
Copy link

@bryfry bryfry commented Apr 24, 2015

No description provided.

@lithammer
Copy link

I believe defer calls are usually after the error handling (if err != nil), because if an error occurred, res might be nil.

 res, err := r.Db("database").Table("tablename").Get(key).Run(session)
-defer res.Close()
 if err != nil {
     // error
 }
+defer res.Close()

@dancannon
Copy link
Collaborator

Thanks I think defering the close is definitely the correct approach when dealing with cursors.

Because @Renstrom is correct about putting the defer after the error check I have updated the documentation in 5a15a4e. I'll close this issue.

@dancannon dancannon closed this May 5, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants