Skip to content

Commit

Permalink
Merge pull request #19 from lesismal/nil_receiver_fields
Browse files Browse the repository at this point in the history
fix nil receiver when struct does not have enough fields
  • Loading branch information
lesismal authored Jan 13, 2024
2 parents 681f98d + 20cfdc1 commit 7be0054
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 7be0054

Please sign in to comment.