/* Package pagination provides utilities to setup a paginator within the context of a http request. Usage In your beego.Controller: package controllers import "github.com/astaxie/beego/utils/pagination" type PostsController struct { beego.Controller } func (this *PostsController) ListAllPosts() { // sets this.Data["paginator"] with the current offset (from the url query param) postsPerPage := 20 paginator := pagination.SetPaginator(this.Ctx, postsPerPage, CountPosts()) // fetch the next 20 posts this.Data["posts"] = ListPostsByOffsetAndLimit(paginator.Offset(), postsPerPage) } In your view templates: {{if .paginator.HasPages}}