From 224a99dec6c9adcd23291cc9996c2daea3764f17 Mon Sep 17 00:00:00 2001 From: Jason Streifling Date: Wed, 1 Nov 2023 11:56:44 +0100 Subject: [PATCH] =?UTF-8?q?Unn=C3=B6tige=20append()=20entfernt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/data/dbFuncs.go | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/packages/data/dbFuncs.go b/packages/data/dbFuncs.go index 221b0dc..5cf80cf 100644 --- a/packages/data/dbFuncs.go +++ b/packages/data/dbFuncs.go @@ -280,20 +280,12 @@ func (db *DB) GetQuestions(nums []string) ([]Question, error) { // TODO: not scalable questions := make([]Question, 0) for rows.Next() { - q := Question{} - a1 := Answer{ID: 1} - a2 := Answer{ID: 2} - a3 := Answer{ID: 3} - a4 := Answer{ID: 4} + q := Question{Answers: make([]Answer, 4)} - if err := rows.Scan(&q.ID, &q.Text, &a1.Text, &a2.Text, &a3.Text, &a4.Text, &q.Correct); err != nil { + if err := rows.Scan(&q.ID, &q.Text, &q.Answers[0], &q.Answers[1], &q.Answers[2], &q.Answers[3], &q.Correct); err != nil { return nil, fmt.Errorf("error: *DB.GetQuestions: rows.Scan(): %v", err) } - q.Answers = append(q.Answers, a1) - q.Answers = append(q.Answers, a2) - q.Answers = append(q.Answers, a3) - q.Answers = append(q.Answers, a4) questions = append(questions, q) }