AI
prepair.app
Start interview →
EnglishРусскийУкраїнська
🦫

Middle Go BackendGolang interview questions

Middle · 2–4 years of experience

Go interviews focus on goroutines, channels, interfaces, and error handling — the language is small, so questions go deep rather than wide. Below are the most common ones with model answers. Middle: deeper understanding, optimization, and real-world situations.

Topics to prepare

Goroutines and the scheduler
Channels and select
Interfaces and composition
Error handling
Slices and maps
Context and cancellation

8 Middle-level questions with answers

1

What is the difference between a buffered and an unbuffered channel?

Answer

An unbuffered channel is synchronous: the sender blocks until a receiver is ready, so it doubles as a synchronisation point. A buffered channel accepts up to its capacity without a waiting receiver and only blocks when full. Use unbuffered when you need a handoff guarantee, buffered to smooth out bursts — but note that a large buffer often hides a design problem rather than solving it.

2

How does select work? What happens if multiple cases are ready?

Answer

select waits on several channel operations and proceeds with whichever is ready. If more than one is ready it picks uniformly at random, which prevents starvation of any single case. A default clause makes the whole statement non-blocking, and a select with no cases at all blocks forever — occasionally used deliberately to park a goroutine.

3

Explain the difference between a slice and an array. How does append work?

Answer

An array has a fixed length that is part of its type and is copied by value. A slice is a header holding a pointer to a backing array, a length, and a capacity, so passing it around copies only the header. append writes into spare capacity when there is room; otherwise it allocates a larger array and copies, which is why the returned slice may no longer share memory with the original — and why you must always assign the result.

4

What is an interface in Go? Why are they called implicit?

Answer

An interface is a set of method signatures; any type that has those methods satisfies it without declaring so. That is what implicit means — there is no implements keyword, so you can define an interface in the consuming package that existing types already satisfy. The idiomatic guidance is to keep interfaces small and define them where they are used, not next to the implementation.

5

How do you handle errors in Go? What is error wrapping with %w?

Answer

Errors are ordinary values returned alongside the result and checked explicitly at each call site. Wrapping with fmt.Errorf and the %w verb preserves the original error inside a new message, so callers can still use errors.Is to test for a sentinel value or errors.As to extract a typed error. Wrapping adds context as the error travels up while keeping it programmatically inspectable.

6

What is context.Context and why is it needed?

Answer

Context carries a cancellation signal, a deadline, and request-scoped values across API boundaries. When a client disconnects or a timeout fires, cancelling the context propagates to every goroutine derived from it, so database queries and HTTP calls abort instead of leaking. Convention is to pass it as the first parameter and never store it in a struct.

7

What is defer? In what order do deferred calls execute?

Answer

defer schedules a call to run when the surrounding function returns, no matter which return path or panic gets there. Deferred calls run in last-in-first-out order, so the most recent defer executes first. Arguments are evaluated at the moment defer is written, not when it runs — a common source of surprise when deferring a call that captures a loop variable.

8

How do you avoid race conditions? Mutex or channels?

Answer

A data race is unsynchronised concurrent access where at least one side writes, and it is detectable with the -race flag. Use sync.Mutex when goroutines share a piece of state and you simply need to serialise access to it. Use channels when you are transferring ownership of data between goroutines — the maxim is to share memory by communicating rather than communicate by sharing memory.

🦎

Reading answers is not enough

In a real interview you speak under pressure. Cam asks these same questions, scores every answer, and shows exactly what to fix.

Practice a Middle Go Backend interview →
Free · 3 interviews per month

Other levels — Go Backend

Junior Go BackendSenior Go BackendAll Go Backend questions

Other specializations

🔍Middle Manual QA🤖Middle QA AutomationMiddle Java Backend🐍Middle Python Backend🐘Middle PHP Backend🟢Middle Node.js Backend⚛️Middle React Frontend💚Middle Vue Frontend🅰️Middle Angular FrontendMiddle Next.js