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

Senior Go BackendGolang interview questions

Senior · 5+ 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. Senior: architecture, trade-offs, mentoring, and decision-making.

Topics to prepare

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

7 Senior-level questions with answers

1

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.

2

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.

3

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.

4

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.

5

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.

6

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.

7

What is a nil interface and why can comparing it to nil surprise you?

Answer

An interface value holds two words: a type and a value. It equals nil only when both are nil. If you assign a nil pointer of a concrete type to an interface, the type word is set, so the interface is non-nil even though the underlying pointer is nil. This is the classic bug where a function returns a nil *MyError as an error and the caller's err != nil check unexpectedly passes.

🦎

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 Senior Go Backend interview →
Free · 3 interviews per month

Other levels — Go Backend

Junior Go BackendMiddle Go BackendAll Go Backend questions

Other specializations

🔍Senior Manual QA🤖Senior QA AutomationSenior Java Backend🐍Senior Python Backend🐘Senior PHP Backend🟢Senior Node.js Backend⚛️Senior React Frontend💚Senior Vue Frontend🅰️Senior Angular FrontendSenior Next.js