From 94dc6d70d3a29827c867cc8fe320de9e2f3813e6 Mon Sep 17 00:00:00 2001 From: loshiqi <553578653@qq.com> Date: Fri, 4 Nov 2022 11:48:50 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0map=E5=88=87=E7=89=87?= =?UTF-8?q?=E6=8E=92=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- map.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/map.go b/map.go index 37d0bb2..6c0f85e 100644 --- a/map.go +++ b/map.go @@ -262,3 +262,17 @@ func MapSort(order, val, val_type string, MapDate []map[string]interface{}) ([]m } return res, nil } +func MapPage(pageNum, pageSize int, MapDate []map[string]interface{}) []map[string]interface{} { + list := []map[string]interface{}{} + stat := (pageNum - 1) * pageSize + end := stat + pageSize - 1 + for k, v := range MapDate { + if k >= stat && k <= end { + list = append(list, v) + } + if k > end { + break + } + } + return list +}