Leere Slices erstellen und mit append() anhängen ersetzt, wo möglich
This commit is contained in:
parent
3b641a90a9
commit
c1b9982533
@ -301,7 +301,7 @@ func (db *DB) GetQuestions(nums []string) ([]Question, error) {
|
||||
}
|
||||
|
||||
func (db *DB) GetGivenAnswers(bid, pid int64, sq []Question) ([]int, error) {
|
||||
answers := make([]int, 0)
|
||||
answers := make([]int, len(sq))
|
||||
query := `
|
||||
SELECT given_answer
|
||||
FROM given_answers
|
||||
@ -311,7 +311,7 @@ func (db *DB) GetGivenAnswers(bid, pid int64, sq []Question) ([]int, error) {
|
||||
question_id = ?
|
||||
`
|
||||
|
||||
for _, q := range sq {
|
||||
for i, q := range sq {
|
||||
var answer int
|
||||
|
||||
row := db.QueryRow(query, bid, pid, q.ID)
|
||||
@ -319,7 +319,7 @@ func (db *DB) GetGivenAnswers(bid, pid int64, sq []Question) ([]int, error) {
|
||||
return nil, fmt.Errorf("error: *DB.GetGivenAnswers: row.Scan(): %v", err)
|
||||
}
|
||||
|
||||
answers = append(answers, answer)
|
||||
answers[i] = answer
|
||||
}
|
||||
|
||||
return answers, nil
|
||||
|
Loading…
x
Reference in New Issue
Block a user