12. Short Q&A Prompts (Practice)
Quick drills to reinforce fundamentals and improve clarity under time pressure.
- What does
go test -race
detect, and when should you run it? - Who should close a channel, and how do receivers detect closure?
- When do you choose
sync.RWMutex
oversync.Mutex
? - What’s the difference between
nil
and empty slices in JSON? - How do
go.mod
andgo.sum
work together? - Why is map iteration order not deterministic, and how to make it stable?
- When should you use
context.Context
, and how do you propagate it? - How do you wait for multiple goroutines to finish?
- What’s the difference between
new
andmake
? - How do you format time as RFC3339 and
YYYY-MM-DD
in Go?
Extra drills
- How do you configure an
http.Client
with timeouts and a customTransport
? - Show the comma-ok idiom for map lookup and type assertion.
- Write a
select
withctx.Done()
timeout and a default case. - Demonstrate
flag
parsing for-port
and-env
with defaults.