Skip to content

Commit

Permalink
Fixed race condition
Browse files Browse the repository at this point in the history
  • Loading branch information
mymmrac committed Jun 21, 2022
1 parent 1c0a5fc commit ddec522
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions common_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package telego

import (
"sync"
"testing"

"github.com/goccy/go-json"
Expand All @@ -12,6 +13,8 @@ import (
)

var (
mutex sync.Mutex

data = &telegoapi.RequestData{}
resp = &telegoapi.Response{
Ok: true,
Expand All @@ -24,6 +27,8 @@ var (

func setResult(t *testing.T, v interface{}) {
t.Helper()
mutex.Lock()
defer mutex.Unlock()

bytesData, err := json.Marshal(v)
assert.NoError(t, err)
Expand Down

0 comments on commit ddec522

Please sign in to comment.