github.com/isyscore/isc-gobase@v1.5.3-0.20231218061332-cbc7451899e9/isc/test/queue_test.go (about) 1 package test 2 3 import ( 4 "fmt" 5 "github.com/isyscore/isc-gobase/isc" 6 "testing" 7 "time" 8 ) 9 10 func TestAdd(t *testing.T) { 11 queue := isc.NewQueue() 12 13 // 返回当前还有多少个 14 num := queue.Offer("dsf") 15 fmt.Println(num) 16 17 // 返回值,以及返回值之后的剩余个数 18 d, n := queue.Poll() 19 fmt.Println(d, n) 20 21 // 获取数据 22 d, n = queue.Take(1 * time.Second) 23 fmt.Println(d, n) 24 25 d, n = queue.Take(1 * time.Second) 26 fmt.Println(d, n) 27 }