listpage

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2026 License: Apache-2.0 Imports: 3 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package listpage pages a list call's results by offset. The page token is the unpadded base64url encoding of the decimal offset of the page's first item, so a token from an older run still decodes.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeOffset

func DecodeOffset(token string) (int, error)

DecodeOffset returns the offset token holds, 0 for "". A token that is not one EncodeOffset made, or holds a negative offset, is INVALID_ARGUMENT.

func EncodeOffset

func EncodeOffset(n int) string

EncodeOffset returns the page token for offset n.

func Offset

func Offset[T any](items []T, token string, size int32, o Options) ([]T, string, error)

Offset returns the page of items that token starts and size bounds, and the token for the next page ("" on the last page).

Types

type Options

type Options struct {
	// Max is the largest page size, and the size when page_size is 0.
	Max int
	// Strict refuses a negative page_size and a token past the end of the
	// list as INVALID_ARGUMENT. Otherwise a negative page_size is Max and a
	// token past the end gives an empty last page.
	Strict bool
}

Options sets how a Service pages.

Jump to

Keyboard shortcuts

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