Skip to content

Commit bf3c504

Browse files
committed
Made "NewMutexMap" to maintain consistency
1 parent e566bac commit bf3c504

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

mutex.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@ type MutexMap struct {
88
core sync.Mutex
99
}
1010

11-
var MutexMapSingleton = MutexMap{}
11+
var MutexMapSingleton = NewMutexMap()
12+
13+
func NewMutexMap() *MutexMap {
14+
return &MutexMap{}
15+
}
1216

1317
func (s *MutexMap) Lock(index string) {
1418
s.core.Lock()

mutex_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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 {
8+
t.Fatal("new mutex map is nil")
9+
}
10+
}

0 commit comments

Comments
 (0)