Created
June 22, 2018 08:52
-
-
Save kitz99/747e9210682cc83f14da474816122ce8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func readRecords() []Post { | |
var result []Post | |
rows, err := roachConnection.Query("select * FROM posts;") | |
if err != nil { | |
log.Fatal(err) | |
} | |
defer rows.Close() | |
for rows.Next() { | |
var post Post | |
if err := rows.Scan(&post.ID, &post.Name, &post.Author, &post.Category, &post.CreatedAt, &post.UpdatedAt); err != nil { | |
log.Fatal(err) | |
} | |
result = append(result, post) | |
} | |
return result | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment