Skip to content

LUSHDigital/go-pagination

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-pagination

This package provides a simple pager object for paginating result sets.

Installation

go get github.com/LUSHDigital/go-pagination

Usage

package main

import (
	"fmt"

	"github.com/LUSHDigital/go-pagination"
)

func main() {
	currentPage := 2
	perPage := 2

	results := []int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}

	total := len(results)

	pager := pagination.NewPager(currentPage, perPage, total)

	fmt.Println(pager.PrevPage) // 1
	fmt.Println(pager.NextPage) // 3
	fmt.Println(pager.LastPage) // 5
}

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages