Skip to content
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

Is there is a leak? #13

Open
mengshu opened this issue Oct 10, 2018 · 0 comments
Open

Is there is a leak? #13

mengshu opened this issue Oct 10, 2018 · 0 comments

Comments

@mengshu
Copy link

mengshu commented Oct 10, 2018

Chapter_6_Storing_Data/sql_store1/store.go

// get all posts
func Posts(limit int) (posts []Post, err error) {
rows, err := Db.Query("select id, content, author from posts limit $1", limit)
if err != nil {
return
}
for rows.Next() {
post := Post{}
err = rows.Scan(&post.Id, &post.Content, &post.Author)
if err != nil {
return ### //here return will cause rows can not close, I think it shoud be using "break"
}
posts = append(posts, post)
}
rows.Close()
return
}

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

No branches or pull requests

1 participant