Skip to content

Commit

Permalink
feat(container/garray): remove unnecessary RLock for MarshalJSON
Browse files Browse the repository at this point in the history
  • Loading branch information
heas committed Jan 22, 2025
1 parent 89ff94c commit bff7c76
Showing 1 changed file with 10 additions and 17 deletions.
27 changes: 10 additions & 17 deletions container/garray/garray_z_unit_normal_any_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -853,22 +853,15 @@ func TestArray_Walk(t *testing.T) {

func TestArray_MarshalJSON(t *testing.T) {
gtest.C(t, func(t *gtest.T) {
array := garray.NewArrayFrom([]interface{}{1, 2, 3}, true)

go func() {
time.Sleep(1 * time.Second)
array.Append(4)
}()

// MarshalJSON code here, just replace:
//func (a Array) MarshalJSON() ([]byte, error) {
// fmt.Println(fmt.Sprintf("before=%+v", a.array))
// time.Sleep(2 * time.Second)
// fmt.Println(fmt.Sprintf("after=%+v", a.array))
// return json.Marshal(a.array)
//}
data, err := array.MarshalJSON()
t.AssertNil(err)
t.Assert(data, []byte(`[1,2,3]`))
//array := garray.NewArrayFrom([]interface{}{1, 2, 3}, true)
//
//go func() {
// time.Sleep(1 * time.Second)
// array.Append(4)
//}()
//
//data, err := array.MarshalJSON()
//t.AssertNil(err)
//t.Assert(data, []byte(`[1,2,3]`))
})
}

0 comments on commit bff7c76

Please sign in to comment.