These Go slice interview questions cover arrays, slices and maps. Together, these types bring more tricky questions than any other basic topic. We collected them from public interview lists, coding tests and community threads. Then we grouped them by idea, so you can revise one part at a time.
This post is questions only, so answer each one in your own words first. When you need help, read Go slices and arrays and Go maps with examples. Also, finish Part 4 on functions first, because many slice questions involve passing slices to functions.
How to Use These Go Slice Interview Questions
Answer each question out loud, then draw the slice header for any question about append. A quick sketch of pointer, length and capacity solves most traps. Finally, try the scenario questions, since they come from real bugs.
The table below lists each section and its number of questions.
| Section | What it tests | Questions |
|---|---|---|
| Arrays | Fixed size and value copies | 12 |
| Slice internals | Header, length and capacity | 16 |
| append and copy | Growth and shared arrays | 16 |
| Slice operations | Slicing, deleting and sorting | 13 |
| Maps | Keys, lookups and iteration | 18 |
| Maps and concurrency | Safe access from goroutines | 10 |
| Code reading | Predict the output | 4 |

Go Slice Interview Questions on Arrays
Before you answer, study Go slices and arrays. Arrays are less common in real code, yet these Go slice interview questions start here because arrays explain how slices work.
- What is an array in Go, and why is its size part of its type?
- Are
[3]intand[4]intthe same type? - What happens when you assign one array to another variable?
- What happens when you pass an array to a function?
- How do you pass an array so the function can change it?
- How do you let the compiler count the elements, such as
[...]int{1, 2, 3}? - Can you compare two arrays with ==?
- Can an array be a map key, while a slice cannot?
- What is the zero value of an array?
- When would you choose an array over a slice in real code, such as for a fixed grid?
- Scenario: when a function changes an array argument and the caller sees no change, why?
- Scenario: when you need a fixed size key such as a 32 byte hash, which type would you pick?
Go Slice Interview Questions on Internals
These Go slice interview questions test how a slice is built underneath. So think in terms of a small header that points to an array.
- What is a slice, and how is it different from an array?
- Which three fields does a slice header hold?
- What is the difference between length and capacity?
- How do you create a slice with make, and what do its arguments mean?
- What is the difference between a nil slice and an empty slice?
- How do a nil slice and an empty slice look when encoded to JSON?
- Why is it safe to call len and append on a nil slice?
- Can you compare two slices with ==, or only with nil?
- How would you check that two slices hold the same elements?
- Why can a slice not be a map key?
- What happens when two slices share the same underlying array?
- How does slicing an existing slice set the new capacity?
- What is a full slice expression, such as
s[low:high:max]? - Why can a small slice keep a huge array alive in memory?
- Scenario: when an API returns null instead of an empty list, how would you fix the slice?
- Scenario: when reading a 1 GB file keeps memory high after you keep only 10 bytes, what is the cause?
Go Slice Interview Questions on append and copy
These are the most common Go slice interview questions, because append hides surprises. So draw each case before you answer.
- How does append work when the slice still has spare capacity?
- When the capacity is full, what does append do?
- How does Go decide the new capacity when a slice grows?
- Why must you always use the value returned by append?
- Can two appends to the same base slice overwrite each other?
- How do you append one slice to another slice?
- What does copy do, and what does it return?
- What happens when the destination of copy is shorter than the source?
- How do you make a full, independent copy of a slice?
- What is slices.Clone, and when would you use it?
- Why does preallocating capacity with make help performance?
- How do you append to a slice inside a function so the caller sees it?
- What is the difference between
make([]int, 5)andmake([]int, 0, 5)? - What bug appears when you append to a slice created with
make([]int, 5)? - Scenario: when two goroutines append to one shared slice, what can go wrong?
- Scenario: when a report shows wrong rows after appending to a sub slice, how would you debug it?
Slice Operations Questions
Daily work needs a few common slice tricks. So these Go slice interview questions ask how you would write them.
- How do you remove an element from the middle of a slice?
- Explain how you insert an element at a given index.
- How do you reverse a slice in place, so no new slice is made?
- Can you filter a slice without allocating a new one, and how?
- Which helpers does the slices package offer, such as Contains and Index?
- How do you sort a slice of ints and a slice of structs?
- What is the difference between sort.Slice and slices.SortFunc?
- How do you remove duplicate values from a slice while you keep the order?
- How do you build a two dimensional slice, for example a 3 by 4 grid?
- Why should you clear deleted pointer elements in a slice?
- How would you split a slice into chunks of 100 items?
- Scenario: when you delete items while looping forward and some are skipped, how would you fix the loop?
- Scenario: when sorting 1 million structs is slow, what would you measure and change?
Go Slice Interview Questions on Maps
Before you answer, study Go maps with examples. Maps appear in almost every coding round, so these questions are common.
- What is a map in Go, and also how is it built inside?
- How do you create a map with make and with a literal?
- What happens when you read a key that does not exist?
- Explain the comma ok idiom, and also why you need it.
- What happens when you write to a nil map?
- Can you read from a nil map without a panic?
- Which types can be map keys, and which types cannot?
- Can a struct be a map key, and when?
- Why is map iteration order random?
- How do you delete a key, and is it safe if the key is missing?
- How do you get the number of entries in a map, and can you get its capacity too?
- Can you take the address of a map element, such as
&m["a"]? - How do you update a field of a struct stored as a map value?
- Is a map passed by value or by reference to a function?
- What does the clear built in do for maps?
- How do you use a map as a set, for example with
map[string]struct{}? - Scenario: when counting words in a large text, how would you use a map?
- Scenario: when a cache map never shrinks after deletes, what would you check?
Maps and Concurrency Questions
Maps are not safe for writes from many goroutines. So the last Go slice interview questions check that you know the safe options.
- Is a plain map safe for concurrent reads and writes?
- What error does Go report when two goroutines write to a map at once?
- How do you protect a map with sync.Mutex?
- When is sync.RWMutex better than sync.Mutex for a map?
- What is sync.Map, and when should you use it?
- Why is sync.Map not the default choice for every shared map?
- How can the race detector help with map bugs?
- How would you build a sharded map to reduce lock contention?
- Scenario: when a web service panics with “concurrent map writes” under load, how would you fix it?
- Scenario: when a read heavy config map is updated once a minute, which approach would you choose?
Code Reading Questions
Read each program and predict the output before you run it. Then explain your answer with a slice header sketch.
package main
import "fmt"
func main() {
base := make([]int, 3, 5)
a := append(base, 10)
b := append(base, 20)
fmt.Println(a[3], b[3], len(base), cap(base))
c := base[1:2]
c = append(c, 99)
fmt.Println(base, c, len(c), cap(c))
}
- Why do a[3] and b[3] show the same number?
- What does the second Println show, and why did base change?
Here is the second program. This time, focus on missing keys and nil maps.
package main
import "fmt"
func main() {
stock := map[string]int{"pen": 0}
qty, ok := stock["pen"]
fmt.Println(qty, ok)
qty, ok = stock["book"]
fmt.Println(qty, ok)
var prices map[string]float64
fmt.Println(len(prices), prices["tea"])
prices["tea"] = 20
}
- What do the first two Println calls show, and how does ok help?
- Which line causes a problem, and what happens when it runs?
Quick Revision Table for Slices and Maps
Use the table below as a final check before your interview. It compares the three types side by side.
| Feature | Array | Slice | Map |
|---|---|---|---|
| Size | Fixed, part of the type | Grows with append | Grows on insert |
| Zero value | All elements zero | nil | nil |
| Compare with == | Yes | Only with nil | Only with nil |
| Can be a map key | Yes, if elements are comparable | No | No |
| Passed to a function | Full copy | Header copy, shared data | Shared data |
Also, many interviewers ask you to compare arrays and slices directly. The diagram below shows the main differences.

Official Resources
These official pages explain the rules behind these questions.
Quick Recap
- These Go slice interview questions cover arrays, slice internals, append, copy and maps.
- A slice is a header with a pointer, a length and a capacity.
- Always use the value returned by append.
- Reading a missing map key gives the zero value, so use the comma ok idiom.
- Writing to a nil map causes a panic.
- Plain maps are not safe for concurrent writes, so add a lock or use sync.Map.
What’s Next?
By now, you have Go slice interview questions for the toughest basic topic. So next, we will cover strings, runes, bytes and UTF-8.
Next up: Go strings interview questions on runes and bytes (Part 6)


