warehouse/utils/pagination.go
2024-11-17 22:08:06 +01:00

15 lines
272 B
Go

package utils
// Paginate returns a slicle with offset & limit
func Paginate[T any](items []T, offset, limit int) []T {
if len(items) <= offset {
return []T{}
}
if limit > len(items)-offset {
limit = len(items) - offset
}
return items[offset : offset+limit]
}