Skip to content

calculating values needed for pagination (NextPage, PrevPage, NumPages, etc.)

License

Notifications You must be signed in to change notification settings

schwarmco/go-pagination

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-pagination

Build Status GoDoc

a package for calculating values needed for pagination in golang

Installation

In order to start, go get this repository:

go get github.com/schwarmco/go-pagination

Usage

import (
    "fmt"
    "github.com/schwarmco/go-pagination"
)

items := []string{"apple", "cherry", "pear", "coconut", "banana"}

// assume, we are on page 1 and want 3 items listed on each page
pager := pagination.Calculate(1, 3, len(items))

fmt.Println(pager.NumPages) // Output: 2
fmt.Println(pager.HasNext) // Output: true
fmt.Println(pager.HasPrev) // Output: false

Todo

  • implement pagination range pattern (like: 1 2 3 .. 7 8 9 ... 12 13 14)

About

calculating values needed for pagination (NextPage, PrevPage, NumPages, etc.)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages