These Go interfaces interview questions cover implicit interfaces, the empty interface, type assertions, type switches, the typed nil trap and interface design. We gathered them from public interview lists, coding rounds and community threads. Then we rewrote them in plain words and grouped them by idea, so you can revise one area at a time.
This post is questions only, so answer each one in your own words first. When you need help, read Go interfaces explained with examples and Go type assertion and type switch. Also, finish Part 7 on structs and pointers first, because method sets decide which types satisfy an interface.
How to Use These Go Interfaces Interview Questions
Answer each of these Go interfaces interview questions out loud, then write a tiny program to prove your answer. Interface bugs often hide until a nil value or a wrong type reaches the code at run time. Finally, try the scenario questions, since they come from real production issues.
The table below lists each section and its number of questions.
| Section | What it tests | Questions |
|---|---|---|
| Interface basics | Declaring and satisfying interfaces | 15 |
| Empty interface and any | any, assertions and type switches | 16 |
| Interface values and nil | Dynamic type, value and typed nil | 15 |
| Interface design | Small interfaces and where to define them | 16 |
| Standard library interfaces | io.Reader, Stringer, error and sort | 15 |
| Interface coding tasks | Classic interview programs | 15 |

Go Interfaces Interview Questions on the Basics
Before you answer, study Go interfaces explained with examples. These Go interfaces interview questions check the rules that every Go developer should know by heart.
- What is an interface in Go, and what does it describe?
- How do you declare an interface type with two methods?
- Why does Go use implicit satisfaction instead of an implements keyword?
- What are the benefits of implicit interfaces for large codebases?
- How can a type satisfy two interfaces at the same time?
- Does a type need to list the interfaces it satisfies anywhere in its code?
- What happens at compile time when a type misses one method of an interface?
- How do you check at compile time that a type satisfies an interface, for example with var _ Shape = (*Circle)(nil)?
- Can an interface hold fields, or only methods?
- What is interface embedding, and how does io.ReadWriter use it?
- Why can a value of type T fail to satisfy an interface when the methods use pointer receivers?
- How do method sets of T and *T affect interface satisfaction?
- When would you define an interface with only one method?
- Scenario: when a new struct compiles but does not satisfy the interface you expected, how would you find the missing method fast?
- Scenario: when a teammate adds a method to a widely used interface and many packages break, how would you fix the design?
Go Interfaces Interview Questions on any and Type Assertions
Before you answer, study Go type assertion and type switch. Interviewers love these Go interfaces interview questions, because one missing ok check can crash a whole service.
- What is the empty interface, and why can it hold a value of any type?
- How is any related to interface{}, and since which Go version can you use it?
- When should you avoid any, so that the compiler can still help you?
- What is a type assertion, and what does x.(T) return?
- Why does a failed type assertion panic, while the comma ok form does not?
- How does the comma ok form work, for example v, ok := x.(int)?
- Can you assert to an interface type instead of a concrete type, and then what does it check?
- What is a type switch, and how does its syntax differ from a normal switch?
- Which type does the variable have inside a case that lists two types?
- How do you match a nil interface value inside a type switch?
- Does the order of cases matter in a type switch, for example when one case is an interface?
- Why does a type switch use a default case, and when can you skip it?
- How do JSON values decoded into any look, for example numbers as float64?
- What is the cost of storing a small value such as an int inside any?
- Scenario: when a handler receives any from a queue and must process three message types, how would you write it safely?
- Scenario: when a service panics with interface conversion: interface is string, not int, what went wrong, and how do you fix it?
Go Interfaces Interview Questions on Interface Values and nil
Before you answer, study Go error handling, because the error type is the most common interface in Go. Many senior candidates still miss the typed nil trap in these Go interfaces interview questions.
- What two parts make up an interface value inside the runtime?
- How does Go decide that an interface value equals nil?
- Why can an interface that holds a nil pointer still compare unequal to nil?
- Explain the typed nil trap with a function that returns error.
- How do you write a function so that it always returns a true nil error?
- Can you call a method on an interface that holds a nil pointer, and when does it panic?
- What happens when you call a method on a nil interface value itself?
- When can you compare two interface values with ==?
- Why does comparing two interfaces that hold slices panic at run time?
- What happens when you use an interface value as a map key, and what can go wrong?
- What is the difference between the static type and the dynamic type of a variable?
- How does fmt print the dynamic type of an interface value with %T?
- Does storing a value in an interface copy it, and what about a pointer?
- Scenario: when a caller sees err != nil but the error message prints as nil, how would you debug it?
- Scenario: when a cache keyed by any panics during a lookup, what would you check first?
Go Interfaces Interview Questions on Design
Before you answer, study Go mocking with interfaces and Go clean architecture. These Go interfaces interview questions test judgement, so explain the trade-off behind each answer.
- Why do Go developers prefer small interfaces with one or two methods?
- What does the saying accept interfaces, return structs mean in practice?
- Where should you define an interface, in the package that uses it or the one that implements it?
- How do interfaces help you write unit tests with fakes and mocks?
- When is an interface premature, and how do you spot one in a code review?
- How can you add behaviour to a type without breaking existing interfaces?
- What are optional interfaces, and how does http.Flusher show the idea?
- How do you check at run time whether a value also supports an optional method?
- Why should a constructor usually return a concrete type instead of an interface?
- When does returning an interface from a function still make sense?
- How do interfaces support dependency injection without a framework?
- What is the difference between an interface and a function type, so when would you pick each?
- How does embedding an interface inside a struct help with partial mocks, and what is the risk?
- How do interface constraints in generics change the way you design small interfaces?
- Scenario: when a service struct depends on a big Store interface with twenty methods, how would you split it?
- Scenario: when every package in a project defines its own copy of the same interface, how would you clean it up?
Interview Questions on Standard Library Interfaces
Before you answer, study Go reader and writer interfaces. Also, these Go interfaces interview questions show how well you know the interfaces that Go itself uses everywhere.
- What methods do io.Reader and io.Writer have, and why are they so small?
- How does io.Copy work with any reader and any writer?
- Which types in the standard library satisfy io.Reader, for example files and network connections?
- What is the fmt.Stringer interface, and when does fmt call it?
- Why can a String method with a value receiver cause infinite recursion when it calls fmt.Sprintf with %v?
- How does the built-in error interface look, and why is it so short?
- What does sort.Interface require, and how does sort.Slice make it easier?
- How does http.Handler let any type serve HTTP requests?
- What is http.HandlerFunc, and how does it turn a function into an interface value?
- Which interface does json.Marshaler define, and when would you implement it?
- How does io.Closer pair with defer in real code?
- What is the purpose of io.ReaderFrom or io.WriterTo in fast copies?
- Why does context.Context use an interface instead of a struct?
- Scenario: when you must count bytes written to an http.ResponseWriter, how would you wrap it?
- Scenario: when a log line shows a struct as a long list of fields, how would you print it in a friendly form?
Go Interfaces Interview Questions for Coding Rounds
Before you answer, study Go interfaces explained with examples again, then write each program by hand. Interviewers watch how you name and size the interface, not only whether the code runs.
- Write a Shape interface with Area and Perimeter, then implement it for a circle and a rectangle.
- Sum the areas of a slice of different shapes using the Shape interface.
- Write a Notifier interface with email and SMS types, then send one message through both.
- Implement fmt.Stringer for a Money type that prints two decimal places.
- Write a type switch that turns any value into a short description.
- Build a tiny plugin registry that maps names to values of an interface type.
- Write a custom error type and return it through the error interface.
- Implement io.Writer for a type that counts how many bytes it receives.
- Wrap an io.Reader so that it turns every letter to upper case.
- Write a fake Store for a unit test instead of a real database.
- Implement sort.Interface for a slice of employees sorted by age.
- Write a middleware that wraps an http.Handler and logs the request path.
- Create a Cache interface, then write two versions, one in memory and one that does nothing.
- Scenario: when an interviewer asks you to add a new payment method without changing old code, how would you design it with interfaces?
- Scenario: when a test needs a clock that you can control, how would you hide time.Now behind an interface?
Code Reading Questions
Read each program carefully and predict the output before you run it. Then explain the result in your own words.
package main
import "fmt"
type Shape interface {
Area() float64
}
type Square struct{ Side float64 }
func (s *Square) Area() float64 {
if s == nil {
return 0
}
return s.Side * s.Side
}
func find(name string) Shape {
var sq *Square
if name == "big" {
sq = &Square{Side: 4}
}
return sq
}
func main() {
a := find("big")
b := find("small")
fmt.Println(a.Area(), b.Area())
fmt.Println(a == nil, b == nil)
fmt.Printf("%T\n", b)
}
- What do the three print lines show, and why is b not equal to nil?
- How would you change find so that the caller can compare the result with nil safely?
The second program mixes a type switch, a Stringer and the comma ok form.
package main
import "fmt"
type Celsius float64
func (c Celsius) String() string {
return fmt.Sprintf("%.1f C", float64(c))
}
func describe(v any) string {
switch x := v.(type) {
case nil:
return "nil"
case fmt.Stringer:
return "stringer: " + x.String()
case int, int64:
return fmt.Sprintf("integer %v", x)
case error:
return "error: " + x.Error()
default:
return fmt.Sprintf("other %T", x)
}
}
func main() {
fmt.Println(describe(Celsius(21.5)))
fmt.Println(describe(42))
fmt.Println(describe(fmt.Errorf("disk full")))
fmt.Println(describe(nil))
fmt.Println(describe([]int{1}))
n, ok := any(3.5).(int)
fmt.Println(n, ok)
}
- Which case runs for each call to describe, and what is the type of x in the int, int64 case?
- Why does the last line print 0 false instead of a panic?
Quick Revision Table for Go Interfaces
Use the table below as a final check before your interview. It compares the two ways to read the type inside an interface.
| Point | Type assertion | Type switch |
|---|---|---|
| Syntax | v, ok := x.(T) | switch v := x.(type) |
| Types checked | One | Many, in order |
| On a miss | Panics without ok | Falls to default |
| Matches nil | No | Yes, with case nil |
| Variable type | Always T | Depends on the case |
| Best for | One expected type | Several possible types |
Also, many interviewers ask you to compare these two tools directly. The diagram below shows the difference side by side.

Official Resources
These official pages explain the rules behind these questions.
- Go specification: Interface types
- A Tour of Go: Interfaces
- Effective Go: Interfaces and other types
- Go FAQ: Why is my nil error value not equal to nil?
Quick Recap
- These Go interfaces interview questions cover basics, any, nil values, design, standard interfaces and coding tasks.
- A type satisfies an interface when it has all the methods, with no implements keyword.
- An interface value holds a dynamic type and a value, so a typed nil is not nil.
- Use the comma ok form or a type switch, because a plain failed assertion panics.
- Keep interfaces small and define them where you use them.
- Know io.Reader, io.Writer, error, fmt.Stringer and http.Handler well.
What’s Next?
By now, you have Go interfaces interview questions for every part of interfaces and types. Study the answers in your own notes, then check them against the Go interview topics study guide.


