# go
// [38] real interview questions. Answers and sources live in the practice app.
practice this topic- Why are goroutines cheaper than OS threads, and what makes 'just spawn a goroutine' idiomatic in Go?(mid)
- When do you use an unbuffered vs a buffered channel, and what do channels give you beyond a queue?(mid)
- A function returns *MyError as error, returns nil on success, yet callers' err != nil checks fire. Explain the nil interface trap.(senior)
- What are the three rules of defer, and what practical gotchas follow from them?(mid)
- How do panic and recover work, and when is recover legitimate in production Go?(mid)
- Why doesn't Go have exceptions, and how does idiomatic error handling work instead?(mid)
- How does context.Context propagate cancellation, and what are the conventions for using it?(mid)
- A teammate wants to pass the database handle and logger through context.Value. What do you tell them?(senior)
- Two slices in your code seem to mutate each other's data. Explain how slices share backing arrays and how append makes it worse.(senior)
- How can a tiny slice keep a huge amount of memory alive, and what is the fix?(senior)
- Should methods be defined on value receivers or pointer receivers? What drives the choice?(mid)
- What happens with closures launched as goroutines inside a loop — and how did Go 1.22 change the answer?(mid)
- Your service crashes with 'fatal error: concurrent map writes'. Why aren't Go maps thread-safe, and what are your options?(mid)
- What are zero values in Go, and how do they shape API design?(junior)
- Why can't you pass a []string directly to a function expecting []interface{}?(mid)
- How does Go manage memory — what roles do the garbage collector and escape analysis play?(mid)
- Concurrency is not parallelism — what does that mean in Go terms?(mid)
- Your Go server's goroutine count climbs steadily and never comes down. What causes goroutine leaks and how do you prevent and find them?(senior)
- A Go service's CPU usage doubled after a release. Walk through profiling it with pprof in production.(senior)
- Since Go 1.18 your team can use generics. What is the official guidance on when type parameters help and when they are the wrong tool?(mid)
- One teammate guards everything with channels 'because it's idiomatic Go'; another uses mutexes everywhere. For a shared in-memory cache and for a work pipeline, what do you actually choose?(mid)
- How do you implement graceful shutdown for a Go HTTP service running in Kubernetes?(mid)
- When do you wrap an error with %w versus %v — and why is wrapping sometimes deliberately the wrong choice?(senior)
- A Go service in Kubernetes has a CPU limit of 2 cores on a 64-core node, and latency is awful with mysterious multi-millisecond stalls. Connect this to GOMAXPROCS.(senior)
- Your Go pod's RSS keeps climbing. How do you tell a real memory leak from normal GC behavior, and what knobs exist?(senior)
- You need to call 20 downstream APIs concurrently for one request: first error should cancel the rest, and concurrency must be capped at 5. What's the idiomatic structure?(mid)
- What does Go's race detector actually detect, what does it miss, and where in your pipeline should it run?(mid)
- Why was time.After inside a hot select loop a known memory problem, and how did Go 1.23 change the story?(mid)
- How should a Go package design its exported errors so callers can react to them without brittle string matching?(mid)
- What actually makes an interface value nil in Go, and how does that shape when interfaces should be small?(mid)
- A goroutine reads a boolean flag another goroutine writes, with no synchronization; it works on your laptop but hangs in production. Why is this a bug even though the flag is 'just a bool'?(senior)
- sync.WaitGroup, errgroup, and a done-channel all coordinate goroutines. For 'wait for N workers to finish', which do you pick and what are the classic WaitGroup mistakes?(mid)
- How do you write table-driven tests with subtests in Go, and what do t.Run, t.Parallel, and t.Cleanup give you?(mid)
- You must call a flaky downstream with a per-attempt timeout, an overall deadline, retries with backoff, and correct cancellation. How do you compose context correctly?(senior)
- When is sync.Pool the right tool, and what are its non-obvious rules that make people misuse it?(mid)
- How does Go modules' version selection actually work, and how do go.mod, go.sum, and semantic import versioning keep builds reproducible?(mid)
- Producers keep pushing to a channel that consumers drain slower, and memory or latency climbs. How do you design backpressure in a Go pipeline?(senior)
- sync.Once, init(), and lazy singletons all set up shared state once. When do you use each, and what are the pitfalls?(mid)