pagination

package
v1.10.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 4, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Page

type Page[T any] struct {
	Items     []T
	NextToken string
	HasMore   bool
}

Page represents a paginated result.

func Paginate

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

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL