(db *sql.DB)
| 15 | } |
| 16 | |
| 17 | func queryDatabase(db *sql.DB) (products []Product, err error) { |
| 18 | rows, err := db.Query(`SELECT Products.Id, Products.Name, Products.Price, |
| 19 | Categories.Id as "Category.Id", Categories.Name as "Category.Name" |
| 20 | FROM Products, Categories |
| 21 | WHERE Products.Category = Categories.Id`) |
| 22 | if (err != nil) { |
| 23 | return |
| 24 | } else { |
| 25 | results, err := scanIntoStruct(rows, &Product{}) |
| 26 | if err == nil { |
| 27 | products = (results).([]Product) |
| 28 | } else { |
| 29 | Printfln("Scanning error: %v", err) |
| 30 | } |
| 31 | } |
| 32 | return |
| 33 | } |
| 34 | |
| 35 | func main() { |
| 36 | db, err := openDatabase() |
no test coverage detected