1. What is a goroutine?
IntermediateAnswer: All of the above
A goroutine is a lightweight thread managed by the Go runtime. Start with `go functionName()`. Goroutines are much cheaper than OS threads.
24 questions that come up in Go technical interviews, each with the answer and an explanation of why it is right.
Test yourself — 90 question bankAnswer: All of the above
A goroutine is a lightweight thread managed by the Go runtime. Start with `go functionName()`. Goroutines are much cheaper than OS threads.
Answer: An open-source programming language created by Google
Go (or Golang) is an open-source, statically typed, compiled programming language designed at Google by Robert Griesemer, Rob Pike, and Ken Thompson.
Answer: All of the above
reflect package provides runtime reflection, allowing inspection and manipulation of types and values. Powerful but comes with performance cost.
Answer: All of the above
Channels are typed conduits for communication between goroutines. Created with make: `ch := make(chan int)`. Send with `ch <- value`, receive with `value := <-ch`.
Answer: All of the above
reflect.Type represents type information, reflect.Value represents runtime value. Get with reflect.TypeOf() and reflect.ValueOf().
Answer: All of the above
unsafe package contains operations that bypass Go type safety. Enables pointer arithmetic, arbitrary type conversion. Use sparingly for performance-critical code.
Answer: All of the above
Buffered channels have a capacity: `make(chan int, 100)`. Sends block only when buffer is full, receives block when empty.
Answer: package main
Every Go program that produces an executable must declare `package main` at the top. The main package is special - it defines a standalone executable.
Answer: All of the above
Escape analysis determines whether variable is allocated on stack or heap. Variables escaping function scope go to heap. Use `go build -gcflags=-m` to see.
Answer: main()
The main() function is the entry point of a Go program. It must be in the main package and takes no arguments and returns nothing.
Answer: All of the above
close(ch) closes a channel, indicating no more values will be sent. Receivers can still receive remaining values. Test with `val, ok := <-ch`.
Answer: All of the above
Inlining replaces function calls with the function body. Reduces call overhead. Compiler automatically inlines small functions. Control with //go:noinline.
Answer: Both b and c
select lets a goroutine wait on multiple channel operations. It blocks until one case can proceed, then executes that case. Similar to switch for channels.
Answer: Both a and b
Go has two ways to declare variables: `var name type` (explicit type) and `name := value` (short declaration with type inference, only inside functions).
Answer: All of the above
Race detector finds data races at runtime. Run with `go test -race` or `go run -race`. Detects unsynchronized access to shared variables.
Answer: Short variable declaration with type inference
The := operator is a short variable declaration that infers the type from the right-hand side. It can only be used inside functions.
Answer: All of the above
An interface is a set of method signatures. Types implement interfaces implicitly by implementing the methods. Enables polymorphism and abstraction.
Answer: char
Go does not have a char type. Characters are represented using rune (alias for int32) or byte (alias for uint8). Basic types include int, float64, string, bool.
Answer: All of the above
The empty interface `interface{}` has no methods, so all types implement it. Can hold any value. Go 1.18+ prefers `any` as alias.
Answer: All of the above
Go memory model specifies conditions under which reads/writes are visible across goroutines. Defines happens-before relationships and synchronization.
Answer: All of the above
pprof profiles running Go programs. Provides CPU, memory, goroutine, and blocking profiles. Essential for performance optimization.
Answer: const name = value
Constants are declared using the `const` keyword: `const Pi = 3.14`. Constants must be assigned at compile time and cannot be changed.
Answer: All of the above
Type assertion extracts the underlying concrete value from an interface: `value, ok := i.(string)`. Use ok to check success.
Answer: All of the above
sync/atomic provides low-level atomic memory operations. Enables lock-free synchronization for simple operations like counters. Faster than mutexes for simple cases.
The full Go bank has 90 questions across 3 difficulty levels — timed, shuffled, and scored.
Take the Go quiz