-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Description
The number of pages is not valid when the totalRecords / perPageInt is a whole number
since it always increases by 1
I propose this solution:
func getTotalPages(perPage string, totalRecords int) int64 {
perPageInt, _ := strconv.ParseInt(perPage, 10, 32)
totalPages := float64(totalRecords) / float64(perPageInt)
b := (totalPages - float64(int64(totalPages)))
if b <= 0 {
return int64(float64(totalPages))
}
// This stupid conversion is needed as golang does not have any round method.
// Chance for creating a new library ??
return int64(float64(totalPages) + float64(1.0))
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels