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{} }