Popularity
0.3
Stable
Activity
0.0
Stable
4
0
0
Description
A simple package to paginate your data in Go.
Programming language: Go
License: MIT License
paginator alternatives and similar packages
Based on the "Utilities" category.
Alternatively, view paginator alternatives based on common mentions on social networks and blogs.
-
项目文档
基于vite+vue3+gin搭建的开发基础平台(已完成setup语法糖版本),集成jwt鉴权,权限管理,动态路由,显隐可控组件,分页封装,多点登录拦截,资源权限,上传下载,代码生成器,表单生成器等开发必备功能。 -
excelize
Go language library for reading and writing Microsoft Excel™ (XLAM / XLSM / XLSX / XLTM / XLTX) spreadsheets -
godotenv
A Go port of Ruby's dotenv library (Loads environment variables from `.env`.) -
hystrix-go
Netflix's Hystrix latency and fault tolerance library, for Go -
gorequest
GoRequest -- Simplified HTTP client ( inspired by nodejs SuperAgent ) -
goreporter
A Golang tool that does static analysis, unit testing, code review and generate code quality report. -
go-funk
A modern Go utility library which provides helpers (map, find, contains, filter, ...) -
mc
MinIO Client is a replacement for ls, cp, mkdir, diff and rsync commands for filesystems and object storage. -
gojson
Automatically generate Go (golang) struct definitions from example JSON -
Kopia
Cross-platform backup tool for Windows, macOS & Linux with fast, incremental backups, client-side end-to-end encryption, compression and data deduplication. CLI and GUI included. -
spinner
Go (golang) package with 90 configurable terminal spinner/progress indicators. -
filetype
Fast, dependency-free Go package to infer binary file types based on the magic numbers header signature -
mole
CLI application to create ssh tunnels focused on resiliency and user experience. -
create-go-app
✨ Create a new production-ready project with backend, frontend and deploy automation by running one CLI command! -
boilr
:zap: boilerplate template manager that generates files or directories from template repositories -
beaver
💨 A real time messaging system to build a scalable in-app notifications, multiplayer games, chat apps in web and mobile apps. -
go-underscore
Helpfully Functional Go - A useful collection of Go utilities. Designed for programmer happiness. -
JobRunner
Framework for performing work asynchronously, outside of the request flow -
git-time-metric
Simple, seamless, lightweight time tracking for Git -
csvtk
A cross-platform, efficient and practical CSV/TSV toolkit in Golang -
mimetype
A fast Golang library for media type and file extension detection, based on magic numbers
Static code analysis for 29 languages.
Your projects are multi-language. So is SonarQube analysis. Find Bugs, Vulnerabilities, Security Hotspots, and Code Smells so you can release quality code every time. Get started analyzing your projects today for free.
Promo
www.sonarqube.org
Do you think we are missing an alternative of paginator or a related project?
README
paginator 
A simple package to paginate your data in Go.
Installation
$ go get github.com/yassinouider/paginator
Usage
In your handler
//This will automatically read the URL query parameter "page" and "per_page" in the request r,
//if they are not present the default values will be chosen
p := paginator.New(r)
Example Server
package main
import "github.com/yassinouider/paginator"
func main() {
http.HandleFunc("/customers", func(w http.ResponseWriter, r *http.Request) {
p := paginator.New(r)
customers, total, _ := getFakeDataStore().FindCustomers(p.Limit(), p.Offset())
res := map[string]interface{}{
"data": customers,
"pagination": p.SetCount(len(customers)).SetTotal(total),
}
b, _ := json.MarshalIndent(res, "", " ")
w.Header().Set("Content-Type", "application/json")
w.Write(b)
})
http.ListenAndServe(":8080", nil)
}
Example Client
resp, err := http.Get("http://localhost:8080/customers?page=2&per_page=2")
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
panic(err)
}
fmt.Println(string(body))
Output
{
"data": [
"User 5",
"User 6"
],
"pagination": {
"total": 7,
"count": 2,
"per_page": 2,
"current_page": 3,
"total_page": 4
}
}
You can change the default values just like this
//default value = 50
paginator.PerPage = 20
//default value = 1000
paginator.PerPageMax = 100
//default value = "page"
paginator.PageName = "p"// http://localhost:8080/customers?p=3
//default value = "per_page"
paginator.PerPageName = "limit" // http://localhost:8080/customers?limit=5