增加map clone

This commit is contained in:
zhangdeman committed 2024-11-06 19:50:09 +08:00
1 parent 5ea67a5b6c
commit fcaa7ee1c2
1 file changed
+31
+31
View File
@@ -44,3 +44,34 @@ func (m *Map) Exist(key string) bool {
_, exist := v[key]
return exist
}
// Value 获取数据值
//
// Author : go_developer@163.com<白茶清欢>
//
// Date : 19:39 2024/11/6
func (m *Map) Value() Map {
if nil == m {
return map[string]any{}
}
return *m
}
// Clone 克隆数据
//
// Author : go_developer@163.com<白茶清欢>
//
// Date : 19:40 2024/11/6
func (m *Map) Clone() Map {
newData := map[string]any{}
if nil == m {
return newData
}
m.rlock()
defer m.unlock()
mapValue := m.Value()
for k, v := range mapValue {
newData[k] = v
}
return newData
}
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.