From 97f7fc4e288c2bb49210072a7a151b58ef44f5b5 Mon Sep 17 00:00:00 2001 From: Elias Schneider Date: Sat, 24 Aug 2024 12:44:02 +0200 Subject: [PATCH] fix: empty lists don't get returned correctly from the api --- backend/internal/dto/dto_mapper.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/backend/internal/dto/dto_mapper.go b/backend/internal/dto/dto_mapper.go index 7769451..b84f1f4 100644 --- a/backend/internal/dto/dto_mapper.go +++ b/backend/internal/dto/dto_mapper.go @@ -7,6 +7,8 @@ import ( // MapStructList maps a list of source structs to a list of destination structs func MapStructList[S any, D any](source []S, destination *[]D) error { + *destination = make([]D, 0, len(source)) + for _, item := range source { var destItem D if err := MapStruct(item, &destItem); err != nil {