1234567891011121314151617181920212223242526272829303132333435 |
- package g
- import (
- "sync"
- "github.com/710leo/urlooker/dataobj"
- )
- type DetectedItemSafeMap struct {
- sync.RWMutex
- M map[string][]*dataobj.DetectedItem
- }
- var (
- DetectedItemMap = &DetectedItemSafeMap{M: make(map[string][]*dataobj.DetectedItem)}
- )
- func (this *DetectedItemSafeMap) Get(key string) ([]*dataobj.DetectedItem, bool) {
- this.RLock()
- defer this.RUnlock()
- ipItem, exists := this.M[key]
- return ipItem, exists
- }
- func (this *DetectedItemSafeMap) GetAll() map[string][]*dataobj.DetectedItem {
- this.RLock()
- defer this.RUnlock()
- return this.M
- }
- func (this *DetectedItemSafeMap) Set(detectedItemMap map[string][]*dataobj.DetectedItem) {
- this.Lock()
- defer this.Unlock()
- this.M = detectedItemMap
- }
|