12. Short Q&A Prompts (Practice)
Quick drills to reinforce fundamentals and improve clarity under time pressure.
- What does
go test -racedetect, and when should you run it? - Who should close a channel, and how do receivers detect closure?
- When do you choose
sync.RWMutexoversync.Mutex? - What’s the difference between
niland empty slices in JSON? - How do
go.modandgo.sumwork 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
newandmake? - How do you format time as RFC3339 and
YYYY-MM-DDin Go?
Extra drills
- How do you configure an
http.Clientwith timeouts and a customTransport? - Show the comma-ok idiom for map lookup and type assertion.
- Write a
selectwithctx.Done()timeout and a default case. - Demonstrate
flagparsing for-portand-envwith defaults.