Update to go1.23

This commit is contained in:
Michel Loiseleur 2024-08-28 15:00:06 +02:00 committed by GitHub
parent d2030a5835
commit e56ae1a766
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
41 changed files with 113 additions and 119 deletions

View file

@ -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
}