github.com/zhongdalu/gf@v1.0.0/g/container/gchan/gchan_example_test.go (about) 1 // Copyright 2018 gf Author(https://github.com/zhongdalu/gf). All Rights Reserved. 2 // 3 // This Source Code Form is subject to the terms of the MIT License. 4 // If a copy of the MIT was not distributed with this file, 5 // You can obtain one at https://github.com/zhongdalu/gf. 6 7 package gchan_test 8 9 import ( 10 "fmt" 11 "github.com/zhongdalu/gf/g/container/gchan" 12 ) 13 14 func Example_basic() { 15 n := 10 16 c := gchan.New(n) 17 for i := 0; i < n; i++ { 18 c.Push(i) 19 } 20 fmt.Println(c.Len(), c.Cap()) 21 for i := 0; i < n; i++ { 22 fmt.Print(c.Pop()) 23 } 24 c.Close() 25 26 // Output: 27 //10 10 28 //0123456789 29 }