Skip to content

Instantly share code, notes, and snippets.

@gavinzhou
Created November 7, 2018 12:07
Show Gist options
  • Select an option

  • Save gavinzhou/398e92a24c9e6cb091b0120093bc1a3d to your computer and use it in GitHub Desktop.

Select an option

Save gavinzhou/398e92a24c9e6cb091b0120093bc1a3d to your computer and use it in GitHub Desktop.
package util
import (
"github.com/Unknwon/com"
"github.com/gin-gonic/gin"
"github.com/gavinzhou/hello-gin/pkg/setting"
)
func GetPage(c *gin.Context) int {
result := 0
page, _ := com.StrTo(c.Query("page")).Int()
if page > 0 {
result = (page - 1) * setting.PageSize
}
return result
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment