Complete the code to create an unbuffered channel of integers.
ch := make(chan [1])The make(chan int) creates an unbuffered channel of integers.
Complete the code to create a buffered channel with capacity 3.
ch := make(chan int, [1])The second argument in make sets the buffer size. Here, 3 means the channel can hold 3 values without blocking.
Fix the error in sending a value to an unbuffered channel without a receiver.
ch := make(chan int) // Send value without receiver ch [1] 10
The send operator is chan <- value. Here, ch <- 10 sends 10 to the channel.
Fill both blanks to create a buffered channel and send a value without blocking.
ch := make(chan int, [1]) ch [2] 5
Creating a buffered channel with capacity 3 allows sending without blocking. The send operator is <-.
Fill all three blanks to receive a value from a buffered channel and print it.
ch := make(chan int, [1]) ch <- 42 value [2] [3] ch fmt.Println(value)
Buffered channel with capacity 3 is created. Receiving uses value := <- ch. This reads a value from the channel.