gitGood.dev

Go (Golang) Interview Questions

Practice Go programming questions covering goroutines, channels, interfaces, error handling, and concurrent programming patterns.

36
Total Questions
8
Easy
20
Medium
8
Hard
Showing 1-20 of 36 questionsPage 1 of 2
Sign up to start practicing these questionsSign up free →
Goroutines vs Threads
QuizEasy
Channel Basics
QuizEasy
Defer Execution Order
QuizEasy
Nil Interface Values
QuizMedium
Slice vs Array
QuizEasy
Error Handling Pattern
QuizEasy
Context Package Purpose
QuizMedium
Select Statement
QuizMedium
Mutex vs RWMutex
QuizMedium
Empty Interface
QuizEasy
Pointer vs Value Receivers
QuizMedium
init() Function
QuizMedium
Type Embedding
QuizMedium
make vs new
QuizEasy
Race Detector
QuizMedium
Panic and Recover
QuizMedium
Generics in Go
QuizMedium
Go Memory Model
QuizHard
Escape Analysis
QuizHard
sync.Pool
QuizHard

Frequently Asked Questions

What Go concepts are commonly tested in interviews?

Goroutines and channels, interfaces and composition, error handling patterns, slices and maps, the sync package (Mutex, WaitGroup), context package, defer/panic/recover, and Go module system. Understanding Go's concurrency model is particularly important.

What companies use Go and might ask Go-specific questions?

Google (creator of Go), Uber, Dropbox, Twitch, Docker, Kubernetes ecosystem companies, and many startups use Go. It's popular for microservices, CLI tools, DevOps tooling, and cloud-native applications. Go's simplicity makes it a common choice for distributed systems.

How do goroutines differ from threads?

Goroutines are lightweight (2KB initial stack vs 1MB for OS threads), managed by Go's runtime scheduler, and support millions of concurrent goroutines. OS threads are heavier and managed by the kernel. Go multiplexes goroutines onto a smaller number of OS threads for efficient concurrency.

When should I use channels vs mutexes in Go?

Use channels for communication between goroutines and coordinating workflows (pipelines, fan-out/fan-in). Use mutexes for protecting shared state when communication is not needed. The Go proverb is 'share memory by communicating' - channels are preferred when they simplify the design.

How does error handling work in Go?

Go uses explicit error returns rather than exceptions. Functions return (result, error) pairs, and callers check if err != nil. Custom errors implement the error interface. Go 1.13+ supports error wrapping with fmt.Errorf and %w, and errors.Is/errors.As for checking error chains.

What is the context package used for?

The context package carries deadlines, cancellation signals, and request-scoped values across API boundaries and goroutines. It is used extensively in HTTP handlers, database calls, and RPC. Always pass context as the first parameter. Use context.WithTimeout and context.WithCancel for resource cleanup.

Explore Other Categories