-
Notifications
You must be signed in to change notification settings - Fork 41
Expand file tree
/
Copy pathtoZSSExhaustive.go
More file actions
37 lines (30 loc) · 861 Bytes
/
Copy pathtoZSSExhaustive.go
File metadata and controls
37 lines (30 loc) · 861 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
//go:build zogmeta
// +build zogmeta
package zog
import "sync"
const (
EXHAUSTIVE_METADATA = true
)
// EXPERIMENTAL. PLEASE DO NOT USE UNLESS YOU KNOW WHAT YOU ARE DOING!
var exMetaRegistry ExMetaRegistry = map[any]map[string]any{}
var exMetaRegistryMu sync.RWMutex
// EXPERIMENTAL. PLEASE DO NOT USE UNLESS YOU KNOW WHAT YOU ARE DOING!
func RegistryAdd(r ExMetaRegistry, key any, path string, value any) {
exMetaRegistryMu.Lock()
defer exMetaRegistryMu.Unlock()
if _, ok := r[key]; !ok {
r[key] = map[string]any{}
}
r[key][path] = value
}
// EXPERIMENTAL. PLEASE DO NOT USE UNLESS YOU KNOW WHAT YOU ARE DOING!
func RegistryGet(r ExMetaRegistry, key any, path string) (any, bool) {
exMetaRegistryMu.RLock()
defer exMetaRegistryMu.RUnlock()
if m, ok := r[key]; ok {
if val, ok := m[path]; ok {
return val, true
}
}
return nil, false
}