Skip to content

Commit 00c8d7e

Browse files
author
anatoly32322
committed
Fix race
1 parent 1a46618 commit 00c8d7e

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

internal/stack/function_id_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package stack
22

33
import (
4+
"sync"
45
"testing"
56
"time"
67

@@ -25,10 +26,17 @@ func (e *starType) starredCall() string {
2526

2627
func anonymousFunctionCall() string {
2728
var result string
29+
var mu sync.Mutex
2830
go func() {
31+
mu.Lock()
32+
defer mu.Unlock()
2933
result = FunctionID("").FunctionID()
3034
}()
3135
time.Sleep(time.Second)
36+
37+
mu.Lock()
38+
defer mu.Unlock()
39+
3240
return result
3341
}
3442

0 commit comments

Comments
 (0)