Continuing with our lockdown learning of Go language. Here’s a video where we discuss Buffered Channels in Golang
package main import ( "fmt" "time" ) func main() { //A channel can buffer data //specify buffer size during creation ch := make(chan int, 3) fmt.Println(cap(ch)) ch <- 1 //Non Blocking ch <- 2 //Non Blocking ch <- 3 //Blocking go printNum(ch) time.Sleep(time.Millisecond) } func printNum(ch chan int) { fmt.Println(<- ch) fmt.Println(<- ch) fmt.Println(<- ch) }
You can watch other videos in Go lang in the links below