From 12b2758d50f26a3a010d1bb99416bb085cb0411a Mon Sep 17 00:00:00 2001 From: Christian Rocha Date: Tue, 2 Jun 2020 18:48:00 -0400 Subject: [PATCH] Fix panic in paginator when setting total items to zero --- paginator/paginator.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/paginator/paginator.go b/paginator/paginator.go index ee6b9eb..1ae0367 100644 --- a/paginator/paginator.go +++ b/paginator/paginator.go @@ -53,6 +53,9 @@ func (m *Model) SetTotalPages(items int) int { // ItemsOnPage is a helper function for returning the numer of items on the // current page given the total numer of items passed as an argument. func (m Model) ItemsOnPage(totalItems int) int { + if totalItems < 1 { + return 0 + } start, end := m.GetSliceBounds(totalItems) return end - start }