From a61f85b4e718d4d4274a04a1901d13b06be94140 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E8=8C=B6=E6=B8=85=E6=AC=A2?= Date: Sat, 14 Oct 2023 22:27:50 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A1=B5=E7=A0=81=E8=AE=A1=E7=AE=97=E9=80=82?= =?UTF-8?q?=E9=85=8D=E6=AF=8F=E9=A1=B5=E6=95=B0=E9=87=8F=E4=B8=BA0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- calculate.go | 3 +++ go.mod | 2 +- go.sum | 4 ++++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/calculate.go b/calculate.go index 164a219..7a393c2 100644 --- a/calculate.go +++ b/calculate.go @@ -21,6 +21,9 @@ type calculate struct { // // Date : 15:50 2022/7/17 func (c *calculate) GetTotalPage(total int64, pageSize int64) int64 { + if pageSize <= 0 { + return 1 + } totalPage := total / pageSize if total%pageSize > 0 { totalPage++ diff --git a/go.mod b/go.mod index 825f060..94fe4fc 100644 --- a/go.mod +++ b/go.mod @@ -14,7 +14,7 @@ require ( github.com/pkg/errors v0.9.1 github.com/spaolacci/murmur3 v1.1.0 github.com/stretchr/testify v1.8.2 - github.com/tidwall/gjson v1.14.4 + github.com/tidwall/gjson v1.17.0 gopkg.in/yaml.v3 v3.0.1 ) diff --git a/go.sum b/go.sum index d7e84c4..0b633cf 100644 --- a/go.sum +++ b/go.sum @@ -32,6 +32,10 @@ github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/tidwall/gjson v1.14.4 h1:uo0p8EbA09J7RQaflQ1aBRffTR7xedD2bcIVSYxLnkM= github.com/tidwall/gjson v1.14.4/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= +github.com/tidwall/gjson v1.15.0 h1:5n/pM+v3r5ujuNl4YLZLsQ+UE5jlkLVm7jMzT5Mpolw= +github.com/tidwall/gjson v1.15.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= +github.com/tidwall/gjson v1.17.0 h1:/Jocvlh98kcTfpN2+JzGQWQcqrPQwDrVEMApx/M5ZwM= +github.com/tidwall/gjson v1.17.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=