Skip to content

Instantly share code, notes, and snippets.

View aruncs31s's full-sized avatar
🌴
On vacation

Arun cs aruncs31s

🌴
On vacation
View GitHub Profile
@aruncs31s
aruncs31s / pagination_meta.go
Created November 2, 2025 02:43
Calculate Pagination Parameter by just by providing limit , offset , totalRecords
func GetPaginationMeta(limit int, offset int, totalRecords uint) interface{} {
return map[string]interface{}{
"totalRecords": totalRecords,
"totalPages": getTotalPages(totalRecords, limit),
"currentPage": getCurrentPage(offset, limit),
"pageSize": limit,
}
}
func getCurrentPage(offset int, limit int) int {
if limit == 0 {