Popularity
0.3
Growing
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的开发基础平台,支持TS和JS混用。它集成了JWT鉴权、权限管理、动态路由、显隐可控组件、分页封装、多点登录拦截、资源权限、上传下载、代码生成器、表单生成器和可配置的导入导出等开发必备功能。 -
excelize
Go language library for reading and writing Microsoft Excel™ (XLAM / XLSM / XLSX / XLTM / XLTX) spreadsheets -
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. -
goreporter
A Golang tool that does static analysis, unit testing, code review and generate code quality report. -
create-go-app
✨ A complete and self-contained solution for developers of any qualification to create a production-ready project with backend (Go), frontend (JavaScript, TypeScript) and deploy automation (Ansible, Docker) by running only one CLI command. -
EaseProbe
A simple, standalone, and lightweight tool that can do health/status checking, written in Go. -
filetype
Fast, dependency-free Go package to infer binary file types based on the magic numbers header signature -
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.
WorkOS - The modern identity platform for B2B SaaS
The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.
Promo
workos.com
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