Discover Packages
github.com/Viridian-Inc/cloudmock
pkg
pagination
package
Version:
v1.10.0
Opens a new window with list of versions in this module.
Published: Aug 4, 2026
License: MIT
Opens a new window with license information.
Imports: 2
Opens a new window with list of imports.
Imported by: 0
Opens a new window with list of known importers.
Documentation
Documentation
¶
type Page[T any ] struct {
Items []T
NextToken string
HasMore bool
}
Page represents a paginated result.
func Paginate[T any ](items []T, token string , maxResults, defaultMax int ) Page [T]
Paginate takes a sorted slice, a token (opaque cursor), and maxResults.
Returns the page of items and the next token.
Token is a base64-encoded index. Empty token means start from beginning.
maxResults <= 0 means use defaultMax.
func PaginateWithFilter[T any ](items []T, token string , maxResults, defaultMax int , filter func(T) bool ) Page [T]
PaginateWithFilter is like Paginate but applies a filter function first.
Source Files
¶
Click to show internal directories.
Click to hide internal directories.