pagination

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package pagination provides generic pagination utilities for cloudemu services.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EncodeToken

func EncodeToken(offset int) string

EncodeToken encodes pagination state into a base64 string.

Types

type Page

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

Page represents a page of results.

func Paginate

func Paginate[T any](items []T, pageToken string, maxResults int) (Page[T], error)

Paginate paginates a slice of items given a page token and max results per page.

type PageToken

type PageToken struct {
	Offset int `json:"offset"`
}

PageToken holds pagination state.

func DecodeToken

func DecodeToken(token string) (PageToken, error)

DecodeToken decodes a page token string into pagination state. Returns offset 0 for empty tokens.

Jump to

Keyboard shortcuts

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