(key string, createFn func() T)
| 64 | } |
| 65 | |
| 66 | func (sm *SyncMap[T]) GetOrCreate(key string, createFn func() T) T { |
| 67 | sm.lock.Lock() |
| 68 | defer sm.lock.Unlock() |
| 69 | if v, ok := sm.m[key]; ok { |
| 70 | return v |
| 71 | } |
| 72 | v := createFn() |
| 73 | sm.m[key] = v |
| 74 | return v |
| 75 | } |
no outgoing calls
no test coverage detected