gitee.com/quant1x/gox@v1.21.2/cache/pool_test.go (about) 1 package cache 2 3 import ( 4 "fmt" 5 "testing" 6 ) 7 8 type TestStruct struct { 9 Name string 10 } 11 12 func TestPool(t *testing.T) { 13 var pool Pool[TestStruct] 14 count := 100 15 var t1 TestStruct 16 t1.Name = "test" 17 pool.Release(&t1) 18 for i := 0; i < count; i++ { 19 t1 := pool.Acquire() 20 fmt.Printf("%d: %p, %+v\n", i, t1, t1) 21 t1.Name = fmt.Sprintf("%d", i) 22 pool.Release(t1) 23 } 24 }