Unnötige append() entfernt
This commit is contained in:
parent
817029c0dc
commit
224a99dec6
@ -280,20 +280,12 @@ func (db *DB) GetQuestions(nums []string) ([]Question, error) {
|
|||||||
// TODO: not scalable
|
// TODO: not scalable
|
||||||
questions := make([]Question, 0)
|
questions := make([]Question, 0)
|
||||||
for rows.Next() {
|
for rows.Next() {
|
||||||
q := Question{}
|
q := Question{Answers: make([]Answer, 4)}
|
||||||
a1 := Answer{ID: 1}
|
|
||||||
a2 := Answer{ID: 2}
|
|
||||||
a3 := Answer{ID: 3}
|
|
||||||
a4 := Answer{ID: 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)
|
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)
|
questions = append(questions, q)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user