func (p paginator) HasPages() (bool, error) {
	n, err := p.Nums()
	if err != nil {
		return false, err
	}
	return n > int64(p.maxPerPage), nil
}
HasPages returns true if there is more than one page
package paginator
import (
	"errors"
	"math"
)
const DefaultMaxPerPage = 10
var (
	ErrNoPrevPage = errors.New("no previous page")
	ErrNoNextPage = errors.New("no next page")
)
type (
	Adapter interface {
		Nums() (int64, error)
		Slice(offset, length int, data interface{}) error
	}
	Paginator interface {
		SetPage(page int)
		Page() (int, error)
		Results(data interface{}) error
		Nums() (int64, error)
		HasPages() (bool, error)
		HasNext() (bool, error)
		PrevPage() (int, error)
		NextPage() (int, error)
		HasPrev() (bool, error)
		PageNums() (int, error)
	}
	paginator struct {
		adapter    Adapter
		maxPerPage int
		page       int
		nums       int64
	}
)
func New(adapter Adapter, maxPerPage int) Paginator {
	if maxPerPage <= 0 {
		maxPerPage = DefaultMaxPerPage
	}
	return &paginator{
		adapter:    adapter,
		maxPerPage: maxPerPage,
		page:       1,
		nums:       -1,
	}
}
func (p *paginator) SetPage(page int) {
	if page <= 0 {
		page = 1
	}
	p.page = page
}
func (p paginator) Page() (int, error) {
	pn, err := p.PageNums()
	if err != nil {
		return 0, err
	}
	if p.page > pn {
		return pn, nil
	}
	return p.page, nil
}
func (p paginator) Results(data interface{}) error {
	var offset int
	page, err := p.Page()
	if err != nil {
		return err
	}
	if page > 1 {
		offset = (page - 1) * p.maxPerPage
	}
	return p.adapter.Slice(offset, p.maxPerPage, data)
}
func (p *paginator) Nums() (int64, error) {
	var err error
	if p.nums == -1 {
		p.nums, err = p.adapter.Nums()
		if err != nil {
			return 0, err
		}
	}
	return p.nums, nil
}