From 20cfdc129719b0136e060bcfdfae48a5d5849cc2 Mon Sep 17 00:00:00 2001 From: lesismal Date: Sat, 13 Jan 2024 17:26:22 +0800 Subject: [PATCH] fix nil receiver when struct does not have enough fields --- convert.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/convert.go b/convert.go index e17f0f8..6752aa2 100644 --- a/convert.go +++ b/convert.go @@ -105,6 +105,8 @@ func rowsToStruct(rows *sql.Rows, dst interface{}, parser FieldParser, mapping * for i, fieldName := range columns { if fieldIdx, ok := fieldIdxMap[fieldName]; ok { row[i] = dstValue.Field(fieldIdx).Addr().Interface() + } else { + row[i] = &Field{} } } if err = rows.Scan(row...); err != nil {