Skip to content
December Code

Go · 8 topic pages · 48 questions in the bank

Go for placements: interview questions by topic

Go is the language behind much of today's cloud infrastructure, from Docker and Kubernetes to countless internal services, and product companies and startups that build backends increasingly ask for it. It is a small language, which makes its interviews precise: with few features to cover, the questions go deep into how each one behaves. What does a slice share with the array it came from? When does a method need a pointer receiver? What does a function see when you pass it a map? What blocks, and what deadlocks?

The answers are rarely about syntax. They come from a few design decisions: values are copied, errors are ordinary return values, interfaces are satisfied without being declared, and concurrency is built from goroutines and channels rather than threads and locks. Knowing those decisions lets you predict what unfamiliar Go code does, which is what an interviewer is really checking.

The pages below take one topic each, with answers whose code was built and run with Go 1.27, and one question exactly as the diagnostic asks it. The diagnostic draws from every Go topic in the bank and names the ones to read first.

New to this? How to prepare for placements — the method — and what the readiness test measures.

On this page3 sections

Go topics, one page each

One question, exactly as the diagnostic asks it

From the Go bank — 48 questions across 8 topics. The answer is marked because this one is public; in a sitting you choose first, then see why each option is right or wrong.

Goroutines & Channels · easyGO-024

What happens when this Go code runs?

Go
ch := make(chan int)
ch <- 1
fmt.Println(<-ch)
  1. 1

    It crashes: fatal error: all goroutines are asleep - deadlock!

    correct
  2. 2

    It prints 1

  3. 3

    It prints 0

  4. 4

    It does not compile: nothing receives from ch

An unbuffered channel has no storage: a send completes only when another goroutine is ready to receive at the same moment. Here main is the only goroutine, and it blocks on ch <- 1 before it ever reaches the receive on the next line. With every goroutine blocked, the Go runtime detects that nothing can make progress and stops the program with fatal error: all goroutines are asleep - deadlock!. It would print 1 with a buffered channel, make(chan int, 1), or with the send moved into its own goroutine. The compiler does not analyse channel usage, so it compiles.

More on this topic: Go goroutines and channels interview questions

Measure it

Reading the answers tells you what’s true. A diagnostic tells you what you get wrong.

10 Go questions across its topics, easy to hard, about fifteen minutes. You get a readiness figure with the arithmetic shown, the topics you missed named, and a practice set sized for today. Free: a diagnostic in every subject, a retake a week and 15 problems a day. No card.

By Harshit · updated