Search and navigate

Pages

Start HereRoadmapTutorialsCheatsheetInterview QuestionsResources

Published tutorials

Building a REST API with Go: The Complete TutorialFan-Out Fan-In in Go: Parallel Work with ChannelsFuzz Testing in Go: Finding Bugs AutomaticallyGeneric Functions in Go: Writing Reusable CodeGo Benchmarking: Measuring Performance with testing.BGo Channel Patterns: Advanced Recipes That WorkGo Channels: Communication Between GoroutinesGo Concurrency Patterns: A Practical CatalogueGo Constraints: comparable, Ordered and Custom SetsGo Context: Cancellation, Deadlines, and Request ValuesGo HTTP Client: Timeouts, JSON, and Reliable RequestsGo HTTP Middleware: Build a Production ChainGo Interview Questions: 25 Answers That Show UnderstandingGo Mutex: Protecting Shared State from Race ConditionsGo net/http: Build an HTTP Server from ScratchGo select Statement: Multiplexing Channels ExplainedGo Tools You Need for a Reliable Development LoopGo Tutorial: From First Program to Backend FoundationsGo Type Parameters: Syntax and Constraints ExplainedGo Worker Pool Pattern: Bounded Concurrency at ScaleGo's Type System Deep Dive: Static Typing Done RightGolang Compilation and Execution ExplainedGolang Developer Salary 2026: US, UK and RemoteGolang File Structure for Modules and ApplicationsGolang Hello World and Your First Go ProgramGolang IDEs: Choose an Editor for Your WorkflowGolang Interfaces: What They Are and How to Use ThemGoroutine Leaks in Go: How to Detect and Prevent ThemGoroutines in Go: Concurrency Without LeaksHow to Download and Install Golang SafelyHow to Learn Golang with a Focused Study PlanIntegration Testing in Go: Testing Real BoundariesJSON in Go: Encoding, Decoding, and ValidationLearn Golang with a Practical Beginner CourseMocking in Go: Test Doubles Without Magicsync.WaitGroup in Go: Coordinating Multiple GoroutinesTable-Driven Tests in Go: The Idiomatic WayTesting in Go: Table Tests, HTTP, Fakes, and CoverageWhat Is Go and How Does a Go Program Work?Why Learn Golang and What Is Go Used For?Writing Unit Tests in Go: A Practical Guide
Open full search and filters →

Go Interview Questions: 25 Answers That Show Understanding

Prepare for Go interviews with concise answers about slices, interfaces, errors, concurrency, context, HTTP, testing, and performance.

Standard-library lessonGo requirement: Go 1.22+How tutorials are checked
Fundamentals · Lesson 14Saved in this browser. No account required.
Workflow showing how a strong Go interview answer moves from a question through behavior, tradeoffs, testing, and a final decision
A strong Go interview answer explains behavior, weighs tradeoffs, verifies the claim, and states a practical decision.

Strong Go interview answers explain behavior, tradeoffs, and how you would verify a claim. Use these questions to identify gaps, then write small programs to test your understanding.

Language and data

1. What is a zero value?

The usable default for a declared value: 0, false, "", nil, or a struct composed of zero-valued fields. Good Go types often make their zero value useful.

2. How are arrays and slices different?

An array has a fixed length that is part of its type. A slice is a descriptor over an underlying array with pointer, length, and capacity.

3. What does append do?

It adds elements and returns the resulting slice. It may reuse the existing array or allocate a new one, so callers must use the returned slice.

4. When do you use a pointer receiver?

When a method mutates the receiver, copying is undesirable, or receiver-method consistency requires it.

5. How does interface satisfaction work?

Implicitly: a type satisfies an interface when its method set contains the required methods.

6. Why can an interface holding a nil pointer be non-nil?

Because the interface still contains a dynamic type even though its dynamic value is nil.

Errors and APIs

7. Why wrap an error with %w?

It adds operation context while preserving the cause for errors.Is and errors.As.

8. Sentinel or typed error?

Use a sentinel for a stable category with no extra data; use a typed error when callers need structured details.

9. When is panic appropriate?

For violated invariants or unrecoverable startup failures, not ordinary input or dependency errors.

10. Where should errors be logged?

Usually once, at the boundary responsible for deciding the operation has failed.

Concurrency

11. What is a goroutine?

A concurrently executing function managed by the Go runtime. Its lifecycle still needs an owner and stop condition.

12. Buffered versus unbuffered channel?

An unbuffered channel synchronizes sender and receiver directly. A buffered channel allows limited decoupling until capacity is full.

13. Who closes a channel?

Normally the sending side that knows no more values will be produced.

14. Mutex or channel?

Use a mutex to protect shared state; use channels to transfer values, coordinate stages, or express ownership.

15. What does the race detector find?

Unsynchronized conflicting memory access observed during a run. It does not prove absence of all races or find every deadlock.

16. What causes goroutine leaks?

Work blocked forever on I/O, channel operations, locks, or timers after its result is no longer needed.

17. What is context for?

Propagating cancellation, deadlines, and limited request-scoped metadata across API boundaries.

18. Why bound concurrency?

To limit memory, sockets, database connections, and pressure on downstream systems.

HTTP, testing, and design

19. Why reuse http.Client?

Its transport pools connections and the client is safe for concurrent use.

20. Why set server timeouts?

To prevent slow or stalled clients from holding resources indefinitely.

21. What is middleware?

A handler wrapper for cross-cutting request behavior such as logging, authentication, or recovery.

22. What is a table-driven test?

A test that runs the same behavior over named input-and-expectation cases, reducing repetition while keeping failures readable.

23. Fake or mock?

Prefer a small fake when state or returned values are enough; use interaction-heavy mocks only when calls themselves are the contract.

24. How do you investigate performance?

Measure with representative benchmarks and profiles, identify the dominant cost, make one change, and measure again.

25. What makes a Go package good?

A focused responsibility, small public API, useful zero values, clear ownership, and minimal knowledge of callers.

In an interview, say what you would measure or test. Frank uncertainty plus a verification plan is stronger than confident guessing.