0
0
Goprogramming~5 mins

Concurrent execution model in Go - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
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?
ABy using 'thread.start()'
BBy calling 'new goroutine()'
CBy importing 'concurrent' package
DBy prefixing a function call with 'go'
What is the main purpose of channels in Go?
ATo store data permanently
BTo create new goroutines
CTo communicate and synchronize between goroutines
DTo handle errors
What happens when a goroutine sends data on an unbuffered channel with no receiver?
AThe program crashes
BThe goroutine blocks until another goroutine receives
CThe data is lost
DThe data is queued automatically
Which Go feature helps run multiple functions at the same time?
AGoroutines
BInterfaces
CStructs
DMaps
What keyword is used to receive data from a channel?
A<-
Bgo
Cchan
Dsend
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.