paging

package
v0.3.4 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2026 License: GPL-3.0 Imports: 2 Imported by: 0

Documentation

Overview

Package paging applies bounded offset/limit windows without integer overflow.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bounds

func Bounds(total, offset, limit int) (start, end int)

Bounds returns a safe half-open slice interval. A negative offset is treated as zero; a negative limit means no limit, while zero requests an empty page.

func PageOffset added in v0.3.4

func PageOffset(page, size int) int

PageOffset saturates a one-based page multiplication rather than overflowing.

func ParseLimit added in v0.3.4

func ParseLimit(raw string, fallback, maximum int) (int, error)

ParseLimit accepts an empty query value as the default and rejects invalid bounds.

func ParseOffset added in v0.3.4

func ParseOffset(raw string, limit int) (int, error)

ParseOffset rejects offsets whose next page could overflow an int.

func Slice

func Slice[T any](items []T, offset, limit int) []T

Slice returns the requested page, preserving the source order.

Types

This section is empty.

Jump to

Keyboard shortcuts

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