GO Cheat Sheet 2026
The 30 highest-yield GO facts, distilled from real exam questions. Print it, save it as a PDF, or study it here — free, no sign-up.
30 questions
50 min time limit
70% to pass
- What file suffix is required for Go test files? → _test.go
- Which statement correctly initializes a struct `Person{Name string; Age int}` with named fields? → Person{Name: "Alice", Age: 30}
- How does Go's `sort.Interface` enable custom sorting? → By implementing Len, Less, and Swap methods on a custom type
- What happens when you send to a full buffered channel with no receiver? → The goroutine blocks until space is available
- What is a goroutine leak? → A goroutine that never terminates and is never garbage collected
- What is a table-driven test in Go? → A test that loops over a slice of input/output pairs to cover many cases in one function
- Which of the following strings package functions are used to manipulate strings in Go? → strings.Contains
- What is the difference between a nil interface and an interface holding a nil pointer? → A nil interface has no type; an interface with a nil pointer has a type but nil value
- Which of the following statements about pointers in Go are true? → A pointer holds the memory address of a value.
- Which channel declaration creates an unbuffered channel of strings? → Both B and C
- Which of the following if conditions are valid in Go? → if x := 10; x > 5 {}
- What happens when you assign one struct variable to another in Go? → A shallow copy is made; the new variable is independent of the original
- Which package provides the `Mutex` type for protecting shared state in Go? → sync
- What command adds a missing dependency to `go.mod`? → go get
- Which built-in Go function can be used to verify at compile time that a type implements an interface? → A blank identifier assignment: `var _ MyInterface = (*MyType)(nil)`
- Which of the following are valid ways to declare and initialize a variable in Go? → var x int = 10
- Which of the following best describes polymorphism in Go? → Using interface variables to call methods on different concrete types
- Which of the following functions are used for memory allocation in Go? → new
- What is the result of receiving from a closed, empty channel in Go? → Returns zero value and false
- What is a nil channel's behavior when read from or written to? → Blocks forever
- What is the fan-out concurrency pattern in Go? → One input channel is read by multiple goroutines in parallel
- Can a Go interface be embedded in another interface? → Yes, to compose larger interfaces from smaller ones
- What file defines a Go module and its dependencies? → go.mod
- How do you skip a test conditionally in Go? → t.Skip() or t.Skipf() with a reason
- Which function registers a cleanup callback in Go tests? → t.Cleanup()
- Which statement about Go's package declaration is true? → Every Go file must start with a package declaration.
- What is the zero value of a struct field of type `*int` in Go? → nil
- What happens if a Go source file imports a package but does not use it? → A compile error occurs
- Which package is primarily used for file handling in Go? → os
- What does `runtime.GOMAXPROCS(n)` do when called with `n > 1`? → Sets the maximum number of OS threads executing Go code simultaneously
Turn these facts into recall: