pagination

package
v0.0.0-...-1f1dc5f Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package pagination normalizes bounded offset pagination.

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalid = errors.New("invalid pagination")

ErrInvalid reports invalid or overflowing pagination input.

Functions

func Bounds

func Bounds(total, offset, limit int) (start, end int, ok bool, err error)

Bounds converts validated offset pagination into safe slice indexes.

Types

type Options

type Options struct {
	DefaultPageSize int
	MaxPageSize     int
}

Options defines the pagination policy for one list endpoint.

type Window

type Window struct {
	Page     int
	PageSize int
	Offset   int
	Limit    int
}

Window is a validated page request translated into store-facing bounds.

func Normalize

func Normalize(page, pageSize int, options Options) (Window, error)

Normalize applies defaults, validates bounds, and rejects offset overflow.

Jump to

Keyboard shortcuts

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