Recall & Review
beginner
What is a channel in Go?
A channel is a way to send and receive values between goroutines safely and synchronously.
Click to reveal answer
beginner
How do you send a value to a channel in Go?
Use the syntax
channel <- value to send a value into the channel.Click to reveal answer
beginner
How do you receive a value from a channel in Go?
Use the syntax
value := <-channel to receive a value from the channel.Click to reveal answer
intermediate
What happens if you try to receive from an empty channel?
The receiving goroutine waits (blocks) until a value is sent to the channel.
Click to reveal answer
intermediate
What happens if you try to send to a full buffered channel?
The sending goroutine waits (blocks) until there is space available in the channel buffer.
Click to reveal answer
How do you send the integer 5 to a channel named ch in Go?
✗ Incorrect
The correct syntax to send a value to a channel is
channel <- value.What does the expression
value := <-ch do?✗ Incorrect
The syntax
value := <-ch receives a value from channel ch.What happens if you send to an unbuffered channel but no goroutine is ready to receive?
✗ Incorrect
Unbuffered channels block the sender until a receiver is ready to receive.
Which of these is true about buffered channels?
✗ Incorrect
Buffered channels block on send if full and block on receive if empty.
How do you declare a channel of integers in Go?
✗ Incorrect
The correct declaration is
var ch chan int.Explain how sending and receiving values on channels works in Go.
Think about how goroutines communicate safely using channels.
You got /4 concepts.
Describe what happens when you send to or receive from a channel that is not ready.
Consider what happens if no goroutine is ready to receive or send.
You got /3 concepts.