extend stdlib to allow import of more packages (#1099)

* stdlib: extend stdlib to allow import of more packages
This commit is contained in:
Cornel
2020-06-23 12:56:28 +03:00
committed by GitHub
parent de45da5df4
commit 720a54a0fe
16 changed files with 549 additions and 13 deletions
+15
View File
@@ -42,3 +42,18 @@ func (m *Map) Store(key, value interface{}) {
}
m.m[key] = value
}
func (m *Map) Range(f func(key, value interface{}) bool) {
m.lock.Lock()
defer m.lock.Unlock()
if m.m == nil {
return
}
for k, v := range m.m {
if !f(k, v) {
break
}
}
}
+11
View File
@@ -74,3 +74,14 @@ type Locker interface {
Lock()
Unlock()
}
// RLocker returns a Locker interface that implements
// the Lock and Unlock methods by calling rw.RLock and rw.RUnlock.
func (rw *RWMutex) RLocker() Locker {
return (*rlocker)(rw)
}
type rlocker RWMutex
func (r *rlocker) Lock() { (*RWMutex)(r).RLock() }
func (r *rlocker) Unlock() { (*RWMutex)(r).RUnlock() }