Go (Golang) Interview Questions
Practice Go programming questions covering goroutines, channels, interfaces, error handling, and concurrent programming patterns.
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.