Interview questions

Go (Golang) Interview Questions

18 Go (Golang) interview questions on goroutines, channels, interfaces, errors, generics and testing, with model answers for both sides of the table.

Go (Golang) Interview Questions

What's here

18 Go (Golang) interview questions, grouped into 4 areas: concurrency, types, interfaces and generics, errors and runtime behaviour and testing, tooling and design. Each one comes with why it is worth asking and what a strong answer contains, so the same question can be scored the same way by different interviewers.

  • Show a short snippet with a concurrency bug and ask the candidate to find it; it reveals more than asking them to define a goroutine
  • Ask candidates to explain the output of a small defer or slice example before running it
  • Probe error handling with a real function signature and ask how they would wrap and check errors
For hiring teams

Cohesyve finds, contacts and tests Go candidates on the real work, then ranks them for these interviews. 14-day free trial for 10 candidates, not charged until it ends.

Preparing for this interview yourself? Practise it free →

Go is used heavily for backend services, infrastructure tools and cloud-native systems. These Go interview questions (also searched as Golang interview questions) cover concurrency with goroutines and channels, interfaces and types, error handling, common runtime pitfalls and testing. Each question has notes on what a strong answer contains, so interviewers can score consistently and candidates can check that they understand the language and not only its syntax.

Concurrency

Concurrency is Go's signature feature and the area where most production bugs hide.

  1. 1

    What is a goroutine, and how does it differ from an operating system thread?

    Why ask it

    The foundation for every other concurrency question.

    What to look for

    A function running concurrently, started with the go keyword, scheduled by the Go runtime onto a smaller number of OS threads. Goroutines are cheap to create compared with threads, so programs can run many of them. Good answers note that cheap does not mean free: leaked goroutines still hold memory.
  2. 2

    Explain the difference between an unbuffered and a buffered channel.

    Why ask it

    Channel semantics drive correctness in concurrent Go code.

    What to look for

    On an unbuffered channel the sender blocks until a receiver has received the value, so it synchronises the two goroutines. A buffered channel lets sends proceed until the buffer is full. Receivers block until there is data. Strong candidates explain when each fits.
  3. 3

    Go's guidance says, 'Do not communicate by sharing memory; instead, share memory by communicating.' What does that mean, and when would you still use a mutex?

    Why ask it

    Tests judgement about concurrency tools.

    What to look for

    Passing ownership of data through channels instead of having many goroutines touch shared state. A mutex from the sync package is still the simpler choice for protecting a small piece of shared state such as a cache or counter. Good answers avoid treating channels as the answer to everything.
  4. 4

    How do you find data races in Go code?

    Why ask it

    Races are common and hard to reproduce.

    What to look for

    Running tests or binaries with the -race flag. Strong answers add that the race detector only finds races in code paths that actually execute, so coverage matters and running a race-enabled build under a realistic workload can find more.
  5. 5

    What is the context package for, and what rules do you follow when using it?

    Why ask it

    Context is everywhere in Go services.

    What to look for

    Carrying deadlines, cancellation signals and request-scoped values across API boundaries. Pass it as the first parameter, usually named ctx; do not store it in structs; always call the cancel function returned by WithCancel, WithTimeout or WithDeadline to avoid leaks; keep values for request-scoped data, not optional parameters.
For hiring teams

Before the Go interviews, see who can do the work

Cohesyve finds and contacts Go candidates from your job description and tests each one on an AI job simulation of the role, so these questions go to a ranked shortlist. 14-day free trial for 10 candidates, not charged until it ends.

Types, Interfaces and Generics

How the candidate designs with Go's type system.

  1. 6

    How does a type implement an interface in Go?

    Why ask it

    Implicit interfaces shape how Go code is designed.

    What to look for

    Implicitly: a type implements an interface by having its methods, with no implements keyword. Good answers explain the consequences: small interfaces defined by the consumer, easy test doubles, and checking satisfaction at compile time with a blank assignment where useful.
  2. 7

    When would you use a pointer receiver instead of a value receiver?

    Why ask it

    A frequent source of subtle bugs.

    What to look for

    Pointer receivers when the method modifies the receiver, when copying would be expensive, or for consistency when other methods use pointers. Value receivers for small immutable types. Strong answers mention that the method set affects which type satisfies an interface.
  3. 8

    Go added generics in version 1.18. When do you use them, and when do you avoid them?

    Why ask it

    Tests modern Go knowledge and restraint.

    What to look for

    Type parameters suit general data structures and algorithms (collections, helpers like Map or Filter) that would otherwise need duplication or interface{} with type assertions. Avoid them where a plain interface or concrete type is clearer. Candidates should know constraint syntax at a basic level.
  4. 9

    What is the zero value, and why does it matter in Go?

    Why ask it

    Idiomatic Go relies on useful zero values.

    What to look for

    Every type has a zero value (0, empty string, nil, a struct with zeroed fields). Well-designed types work at their zero value, as sync.Mutex does. Candidates should also know which zero values are dangerous, such as a nil map.

Errors and Runtime Behaviour

How the candidate handles failure and avoids common runtime panics.

  1. 10

    How does error handling work in Go, and how do you add context to an error?

    Why ask it

    Error handling is a daily part of Go code.

    What to look for

    Errors are values implementing the built-in error interface, returned and checked explicitly. Since Go 1.13, fmt.Errorf with %w wraps an error, and errors.Is and errors.As check the chain for a value or a type. Strong answers mention wrapping with useful context and not logging and returning the same error twice.
  2. 11

    What do panic and recover do, and when is it appropriate to use them?

    Why ask it

    Misusing panic is a common anti-pattern.

    What to look for

    panic stops the current function and unwinds the goroutine's stack, running deferred functions; recover stops the unwinding but only works inside a deferred function. Use panic for truly unrecoverable programmer errors; return errors for expected failures. A recover at a server's request boundary is a reasonable example.
  3. 12

    In what order do deferred calls run, and what is a common mistake with defer?

    Why ask it

    Defer semantics catch people out.

    What to look for

    Deferred calls run when the surrounding function returns, in last-in, first-out order. Common mistakes: deferring inside a long loop so resources are not released until the function ends, and forgetting that arguments are evaluated when the defer statement runs.
  4. 13

    Name two operations that cause a run-time panic that a code review should catch.

    Why ask it

    Tests practical knowledge of the language specification.

    What to look for

    Assigning to an element of a nil map, and sending on a closed channel, both cause run-time panics. Other good examples: out-of-range index, nil pointer dereference and failed type assertions without the two-value form.
  5. 14

    Two slices seem to change each other's data. What is going on?

    Why ask it

    Slice aliasing is a classic Go bug.

    What to look for

    Slices share an underlying array; slicing does not copy, and append writes into the shared array when capacity allows. Fixes include copying with copy() or using a full slice expression to limit capacity.

Testing, Tooling and Design

How the candidate builds and maintains Go services in a team.

  1. 15

    How do you structure tests in Go?

    Why ask it

    Testing practice is a strong signal of seniority.

    What to look for

    The standard testing package, table-driven tests with subtests, test doubles through small interfaces, benchmarks for hot paths, and fuzz tests (added in Go 1.18) for parsers and input handling. Running tests with -race in CI is a plus.
  2. 16

    How would you find and fix a goroutine leak in a long-running service?

    Why ask it

    A realistic production problem.

    What to look for

    Watching goroutine counts over time, using profiling tools to see where goroutines are blocked, then fixing the cause: missing cancellation, a channel nobody reads, or a missing timeout. Prevention through context cancellation and clear ownership of goroutine lifetimes.
  3. 17

    How do you organise packages in a medium-sized Go service?

    Why ask it

    Package design affects maintainability.

    What to look for

    Packages by domain or responsibility rather than by layer type alone, small public APIs, avoiding circular dependencies, using internal/ for code not meant for import, and keeping main thin. Go modules (go.mod) for dependencies.
  4. 18

    How would you design a worker pool that processes jobs concurrently and shuts down cleanly?

    Why ask it

    Combines channels, synchronisation and cancellation in one design.

    What to look for

    A jobs channel, a fixed number of worker goroutines, a results or error path, a sync.WaitGroup to wait for workers, context for cancellation, and closing the jobs channel from the sender side only. Strong answers discuss back-pressure and error handling.

Running the interview well

  • 1Show a short snippet with a concurrency bug and ask the candidate to find it; it reveals more than asking them to define a goroutine
  • 2Ask candidates to explain the output of a small defer or slice example before running it
  • 3Probe error handling with a real function signature and ask how they would wrap and check errors
  • 4For senior roles, ask for a design (worker pool, rate limiter, graceful shutdown) and listen for cancellation and ownership
  • 5Check whether they write table-driven tests naturally if there is a coding exercise
  • 6Score idiomatic simplicity; Go teams value clear code over clever abstractions

Common questions

Is it Go or Golang?

The language is called Go. 'Golang' comes from the old website address and is widely used in job ads and searches because 'Go' alone is hard to search for. Interview questions are the same under either name.

What Go topics are most common in interviews?

Goroutines and channels, select, sync primitives and the race detector, context, interfaces and pointer versus value receivers, error handling with wrapping, defer and panic, slices and maps, generics, testing and package design.

How should I prepare for a Go interview?

Write small concurrent programs, such as a worker pool with cancellation, and run them with the race detector. Review error wrapping with errors.Is and errors.As, slice behaviour and common panics. Be ready to explain a Go service you built and the trade-offs you made.

When were generics added to Go?

Go 1.18 added generics through type parameters, along with built-in fuzz testing.

Do Go interviews include coding exercises?

Many do, either live or as a take-home task. Expect problems that use concurrency, error handling and tests. Interviewers usually look for idiomatic, readable code as much as a working answer.

For hiring teams

Save these questions for the Go candidates who can do the work

Cohesyve takes your Go job description, finds candidates, reaches out to them and runs an AI job simulation of the real work, then returns a ranked shortlist.

1,500+

assessments completed

50%

faster time-to-hire

5 min

from JD to assessment

14-day free trial · 10 candidates · Not charged until the trial ends

For job seekers

Preparing for a Go interview yourself? Practise on an AI job simulation of the role. 3-day free trial, cancel anytime.

Practise a Go interview free →

See Cohesyve in action

Free 30-min walkthrough

See it on your role