We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent e566bac commit bf3c504Copy full SHA for bf3c504
mutex.go
@@ -8,7 +8,11 @@ type MutexMap struct {
8
core sync.Mutex
9
}
10
11
-var MutexMapSingleton = MutexMap{}
+var MutexMapSingleton = NewMutexMap()
12
+
13
+func NewMutexMap() *MutexMap {
14
+ return &MutexMap{}
15
+}
16
17
func (s *MutexMap) Lock(index string) {
18
s.core.Lock()
mutex_test.go
@@ -0,0 +1,10 @@
1
+package work
2
3
+import "testing"
4
5
+func TestNewMutexMap(t *testing.T) {
6
+ b1 := NewMutexMap()
7
+ if b1 == nil {
+ t.Fatal("new mutex map is nil")
+ }
0 commit comments