From ddb048c5c9dd6ae26361bb10f97649d53741c0d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E8=8C=B6=E6=B8=85=E6=AC=A2?= Date: Wed, 15 Sep 2021 21:51:13 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8D=87=E7=BA=A7easymap?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- easymap/abstruct.go | 1 + easymap/normal.go | 15 +++++++++++++++ easymap/segment.go | 16 ++++++++++++++++ easymap/sync_normal.go | 15 +++++++++++++++ easymap/sync_segment.go | 16 ++++++++++++++++ 5 files changed, 63 insertions(+) diff --git a/easymap/abstruct.go b/easymap/abstruct.go index d510fa4..b4fff5b 100644 --- a/easymap/abstruct.go +++ b/easymap/abstruct.go @@ -33,4 +33,5 @@ type EasyMap interface { Del(key interface{}) Exist(key interface{}) bool GetAll() map[interface{}]interface{} + GetAllForMapKeyString() map[string]interface{} } diff --git a/easymap/normal.go b/easymap/normal.go index 8309cac..af983ab 100644 --- a/easymap/normal.go +++ b/easymap/normal.go @@ -8,6 +8,7 @@ package easymap import ( + "fmt" "sync" "git.zhangdeman.cn/zhangdeman/gopkg/convert" @@ -271,3 +272,17 @@ func (n *normal) Unlock() { n.lock.Unlock() } } + +// GetAllForMapKeyString ... +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 9:48 下午 2021/9/15 +func (n *normal) GetAllForMapKeyString() map[string]interface{} { + fullData := n.GetAll() + finalData := make(map[string]interface{}) + for k, v := range fullData { + finalData[fmt.Sprintf("%v", k)] = v + } + return finalData +} diff --git a/easymap/segment.go b/easymap/segment.go index 7a04ff2..8f0835b 100644 --- a/easymap/segment.go +++ b/easymap/segment.go @@ -8,6 +8,8 @@ package easymap import ( + "fmt" + "git.zhangdeman.cn/zhangdeman/gopkg/util" ) @@ -139,3 +141,17 @@ func (s *segment) GetAll() map[interface{}]interface{} { } return result } + +// GetAllForMapKeyString ... +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 9:48 下午 2021/9/15 +func (s *segment) GetAllForMapKeyString() map[string]interface{} { + fullData := s.GetAll() + finalData := make(map[string]interface{}) + for k, v := range fullData { + finalData[fmt.Sprintf("%v", k)] = v + } + return finalData +} diff --git a/easymap/sync_normal.go b/easymap/sync_normal.go index f72dece..9b758d3 100644 --- a/easymap/sync_normal.go +++ b/easymap/sync_normal.go @@ -8,6 +8,7 @@ package easymap import ( + "fmt" "sync" "git.zhangdeman.cn/zhangdeman/gopkg/convert" @@ -218,3 +219,17 @@ func (s *syncMap) GetAll() map[interface{}]interface{} { }) return result } + +// GetAllForMapKeyString ... +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 9:48 下午 2021/9/15 +func (s *syncMap) GetAllForMapKeyString() map[string]interface{} { + fullData := s.GetAll() + finalData := make(map[string]interface{}) + for k, v := range fullData { + finalData[fmt.Sprintf("%v", k)] = v + } + return finalData +} diff --git a/easymap/sync_segment.go b/easymap/sync_segment.go index d999e35..50ccb32 100644 --- a/easymap/sync_segment.go +++ b/easymap/sync_segment.go @@ -8,6 +8,8 @@ package easymap import ( + "fmt" + "git.zhangdeman.cn/zhangdeman/gopkg/util" ) @@ -120,3 +122,17 @@ func (s *segmentSync) GetAll() map[interface{}]interface{} { } return result } + +// GetAllForMapKeyString ... +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 9:48 下午 2021/9/15 +func (s *segmentSync) GetAllForMapKeyString() map[string]interface{} { + fullData := s.GetAll() + finalData := make(map[string]interface{}) + for k, v := range fullData { + finalData[fmt.Sprintf("%v", k)] = v + } + return finalData +}