As far as I understand from this question, " Golang - What is channel buffer size? ", If the channel is buffered, it will not be blocked.
c := make(chan int, 1)
c <- data1
c <- data2
c <- data3
c <- data4
But I do not understand what its use is. Suppose that if I have 2 goroutines, the first will receive data1, and the second will receive data2, then it will be blocked until some routines are freed for data processing3.
I don’t understand, what's the difference? This would also be done without a buffer. Can you explain a possible scenario when buffering is useful?
source
share