15 lines
272 B
Go
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]
|
||
|
}
|