Skip to content

Commit

Permalink
fix: IterToStructs return
Browse files Browse the repository at this point in the history
In case of an empty result, return an empty slice
instead of nil
  • Loading branch information
Dov committed Jan 16, 2024
1 parent 8f76085 commit cb4d4f5
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion gcloud/helpers/spanner/iter.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func GetOneWithIterator(iter *spanner.RowIterator) (row *spanner.Row, exist bool
// IterToStructs is a helper function to process a row iterator and convert each row to a struct
// This function will return an array of structs and/or the spanner error if one occurs.
func IterToStructs[T any](iter *spanner.RowIterator) ([]T, error) {
var results []T
var results = make([]T, 0)

err := iter.Do(func(r *spanner.Row) error {
var dest T
Expand Down

0 comments on commit cb4d4f5

Please sign in to comment.