paginate

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertPageEquals added in v0.5.0

func AssertPageEquals(t *testing.T, got, want Page)

AssertPageEquals asserts that two pages are equal.

func GetPageNumber

func GetPageNumber(urlQuery url.Values) (uint, string, error)

GetPageNumber retrieves or sets the page number for paginated views.

func PageCount

func PageCount(itemCount, itemsPerPage uint) uint

PageCount returns the total number of pages for a given number of items and items per page.

Types

type Page added in v0.5.0

type Page struct {
	// The number of the current page.
	PageNumber uint

	// The number of the previous page.
	PreviousPageNumber uint

	// The number of the next page.
	NextPageNumber uint

	// The total number of pages.
	TotalPages uint

	// The number of pages left.
	PagesLeft uint

	// The total number of items.
	ItemCount uint

	// The offset of the first item on the current page.
	ItemOffset uint

	// Terms used in a search query.
	SearchTerms string
}

A Page holds pagination metadata.

func NewPage added in v0.5.0

func NewPage(pageNumber uint, totalPages uint, itemsPerPage uint, itemCount uint) Page

NewPage initializes and returns a new Page.

Jump to

Keyboard shortcuts

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