47 lines
653 B
Go
47 lines
653 B
Go
// Package wrapper ...
|
|
//
|
|
// Description : wrapper ...
|
|
//
|
|
// Author : go_developer@163.com<白茶清欢>
|
|
//
|
|
// Date : 2024-11-06 18:27
|
|
package wrapper
|
|
|
|
import "sync"
|
|
|
|
var mapLock = &sync.RWMutex{}
|
|
|
|
type Map map[string]any
|
|
|
|
func (m *Map) lock() {
|
|
mapLock.Lock()
|
|
}
|
|
|
|
func (m *Map) unlock() {
|
|
mapLock.Unlock()
|
|
}
|
|
|
|
func (m *Map) rlock() {
|
|
mapLock.RLock()
|
|
}
|
|
|
|
func (m *Map) rUnlock() {
|
|
mapLock.RUnlock()
|
|
}
|
|
|
|
// Exist key是否存在
|
|
//
|
|
// Author : go_developer@163.com<白茶清欢>
|
|
//
|
|
// Date : 18:34 2024/11/6
|
|
func (m *Map) Exist(key string) bool {
|
|
if nil == m {
|
|
return false
|
|
}
|
|
m.rlock()
|
|
defer m.unlock()
|
|
v := *m
|
|
_, exist := v[key]
|
|
return exist
|
|
}
|