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
  1. What file suffix is required for Go test files? _test.go
  2. Which statement correctly initializes a struct `Person{Name string; Age int}` with named fields? Person{Name: "Alice", Age: 30}
  3. How does Go's `sort.Interface` enable custom sorting? By implementing Len, Less, and Swap methods on a custom type
  4. What happens when you send to a full buffered channel with no receiver? The goroutine blocks until space is available
  5. What is a goroutine leak? A goroutine that never terminates and is never garbage collected
  6. 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
  7. Which of the following strings package functions are used to manipulate strings in Go? strings.Contains
  8. 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
  9. Which of the following statements about pointers in Go are true? A pointer holds the memory address of a value.
  10. Which channel declaration creates an unbuffered channel of strings? Both B and C
  11. Which of the following if conditions are valid in Go? if x := 10; x > 5 {}
  12. 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
  13. Which package provides the `Mutex` type for protecting shared state in Go? sync
  14. What command adds a missing dependency to `go.mod`? go get
  15. 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)`
  16. Which of the following are valid ways to declare and initialize a variable in Go? var x int = 10
  17. Which of the following best describes polymorphism in Go? Using interface variables to call methods on different concrete types
  18. Which of the following functions are used for memory allocation in Go? new
  19. What is the result of receiving from a closed, empty channel in Go? Returns zero value and false
  20. What is a nil channel's behavior when read from or written to? Blocks forever
  21. What is the fan-out concurrency pattern in Go? One input channel is read by multiple goroutines in parallel
  22. Can a Go interface be embedded in another interface? Yes, to compose larger interfaces from smaller ones
  23. What file defines a Go module and its dependencies? go.mod
  24. How do you skip a test conditionally in Go? t.Skip() or t.Skipf() with a reason
  25. Which function registers a cleanup callback in Go tests? t.Cleanup()
  26. Which statement about Go's package declaration is true? Every Go file must start with a package declaration.
  27. What is the zero value of a struct field of type `*int` in Go? nil
  28. What happens if a Go source file imports a package but does not use it? A compile error occurs
  29. Which package is primarily used for file handling in Go? os
  30. 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: