From 29b0f171ff8a664ecda84892abb7c32641231f1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E8=8C=B6=E6=B8=85=E6=AC=A2?= Date: Sun, 17 Jul 2022 15:51:53 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=AE=A1=E7=AE=97=E7=9B=B8?= =?UTF-8?q?=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- calculate.go | 29 +++++++++++++++++++++++++++++ init.go | 3 +++ 2 files changed, 32 insertions(+) create mode 100644 calculate.go diff --git a/calculate.go b/calculate.go new file mode 100644 index 0000000..164a219 --- /dev/null +++ b/calculate.go @@ -0,0 +1,29 @@ +// Package util ... +// +// Description : util ... +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 2022-07-17 15:49 +package util + +// calculate 各种计算相关 +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 15:49 2022/7/17 +type calculate struct { +} + +// GetTotalPage 获取总页码数 +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 15:50 2022/7/17 +func (c *calculate) GetTotalPage(total int64, pageSize int64) int64 { + totalPage := total / pageSize + if total%pageSize > 0 { + totalPage++ + } + return totalPage +} diff --git a/init.go b/init.go index 9265efd..8bf86d8 100644 --- a/init.go +++ b/init.go @@ -28,6 +28,8 @@ var ( URL *ownURL // Map ... Map *ownMap + // Calculate ... + Calculate *calculate ) func init() { @@ -41,4 +43,5 @@ func init() { Time = &ownTime{} URL = &ownURL{} Map = &ownMap{} + Calculate = &calculate{} }