升级easymap

This commit is contained in:
白茶清欢 2021-09-15 21:51:13 +08:00
parent d261c4eb1a
commit ddb048c5c9
5 changed files with 63 additions and 0 deletions

View File

@ -33,4 +33,5 @@ type EasyMap interface {
Del(key interface{})
Exist(key interface{}) bool
GetAll() map[interface{}]interface{}
GetAllForMapKeyString() map[string]interface{}
}

View File

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

View File

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

View File

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

View File

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