Update to go1.23
This commit is contained in:
parent
d2030a5835
commit
e56ae1a766
41 changed files with 113 additions and 119 deletions
|
@ -56,7 +56,7 @@ func (c *searchCriterion) searchIn(values ...string) bool {
|
|||
})
|
||||
}
|
||||
|
||||
func pagination(request *http.Request, max int) (pageInfo, error) {
|
||||
func pagination(request *http.Request, maximum int) (pageInfo, error) {
|
||||
perPage, err := getIntParam(request, "per_page", defaultPerPage)
|
||||
if err != nil {
|
||||
return pageInfo{}, err
|
||||
|
@ -68,17 +68,17 @@ func pagination(request *http.Request, max int) (pageInfo, error) {
|
|||
}
|
||||
|
||||
startIndex := (page - 1) * perPage
|
||||
if startIndex != 0 && startIndex >= max {
|
||||
if startIndex != 0 && startIndex >= maximum {
|
||||
return pageInfo{}, fmt.Errorf("invalid request: page: %d, per_page: %d", page, perPage)
|
||||
}
|
||||
|
||||
endIndex := startIndex + perPage
|
||||
if endIndex >= max {
|
||||
endIndex = max
|
||||
if endIndex >= maximum {
|
||||
endIndex = maximum
|
||||
}
|
||||
|
||||
nextPage := 1
|
||||
if page*perPage < max {
|
||||
if page*perPage < maximum {
|
||||
nextPage = page + 1
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue