Recall & Review
beginner
What is a goroutine in Go?
A goroutine is a lightweight thread managed by the Go runtime. It allows functions to run concurrently without the overhead of traditional threads.
Click to reveal answer
beginner
How do you start a goroutine?
Use the keyword
go before a function call, like go myFunction(), to start it as a goroutine.Click to reveal answer
intermediate
What is a channel in Go's concurrent model?
A channel is a typed conduit through which goroutines communicate by sending and receiving values, helping to synchronize execution.
Click to reveal answer
beginner
Why is concurrency important in Go?
Concurrency lets Go programs handle multiple tasks at once, improving efficiency and responsiveness, especially for I/O or network operations.
Click to reveal answer
intermediate
What happens if a goroutine tries to send on a channel but no one is receiving?
The goroutine blocks (waits) until another goroutine receives from the channel, ensuring safe communication without data loss.
Click to reveal answer
How do you create a new goroutine in Go?
✗ Incorrect
In Go, you start a goroutine by prefixing a function call with the keyword 'go'.
What is the main purpose of channels in Go?
✗ Incorrect
Channels allow goroutines to send and receive data, enabling communication and synchronization.
What happens when a goroutine sends data on an unbuffered channel with no receiver?
✗ Incorrect
Sending on an unbuffered channel blocks the sender until a receiver is ready.
Which Go feature helps run multiple functions at the same time?
✗ Incorrect
Goroutines allow concurrent execution of functions.
What keyword is used to receive data from a channel?
✗ Incorrect
The '<-' operator is used to send or receive data on channels.
Explain how goroutines and channels work together in Go's concurrent execution model.
Think about how two friends pass notes to coordinate their work.
You got /4 concepts.
Describe what happens when you start a goroutine and how it differs from a normal function call.
Imagine starting a new task that runs alongside your current one.
You got /4 concepts.