You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// 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
}
The text was updated successfully, but these errors were encountered:
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
}
The text was updated successfully, but these errors were encountered: