func (r *GormWorkItemLinkRepository) list(ctx context.Context, fetchFunc fetchLinksFunc) (*app.WorkItemLinkList, error) { rows, err := fetchFunc() if err != nil { return nil, errs.WithStack(err) } res := app.WorkItemLinkList{} res.Data = make([]*app.WorkItemLinkData, len(rows)) for index, value := range rows { cat := ConvertLinkFromModel(value) res.Data[index] = cat.Data } // TODO: When adding pagination, this must not be len(rows) but // the overall total number of elements from all pages. res.Meta = &app.WorkItemLinkListMeta{ TotalCount: len(rows), } return &res, nil }