github.com/sandwich-go/boost@v1.3.29/xchan/README.md (about) 1 # xchan 2 3 https://colobu.com/2021/05/11/unbounded-channel-in-go/ 4 5 Unbounded chan with ring buffer. 6 7 Refer to the below articles and issues: 8 1. https://github.com/golang/go/issues/20352 9 2. https://stackoverflow.com/questions/41906146/why-go-channels-limit-the-buffer-size 10 3. https://medium.com/capital-one-tech/building-an-unbounded-channel-in-go-789e175cd2cd 11 4. https://erikwinter.nl/articles/2020/channel-with-infinite-buffer-in-golang/ 12 13 14 ## Usage 15 16 ```go 17 ch := NewUnboundedChan(1000) 18 // or ch := NewUnboundedChanSize(10,200,1000) 19 20 go func() { 21 for ...... { 22 ... 23 ch.In <- ... // send values 24 ... 25 } 26 27 close(ch.In) // close In channel 28 }() 29 30 31 for v := range ch.Out { // read values 32 fmt.Println(v) 33 } 34 35 ```