Go Quiz
Thirty questions covering the whole course. Choose an answer for each, then press Check answers at the bottom to see your score and an explanation for every question.
1. What happens if a Go file imports a package it never uses?
Unused imports and unused local variables are compile errors (lesson 03).
2. Which command runs the package in the current folder of a module?
The dot means "the package in this folder", so every file in it is compiled (lesson 04).
3. What is the zero value of a string variable?
Every type has a zero value; strings start empty (lesson 06).
4. What does len("Café") return?
len counts bytes, and é takes two bytes in UTF-8 (lessons 07 and 19).
5. What does 7 / 2 evaluate to when both operands are int?
Integer division discards the fraction (lesson 08).
6. What do the constants in const ( A = iota; B; C ) equal?
iota starts at 0 and the expression is repeated for B and C (lesson 10).
7. Why does string(65) usually indicate a bug?
go vet reports this conversion (lesson 09).
8. In a Go switch, what happens after a matching case's code runs?
(lesson 15)
9. How does Go write a "while" loop?
for is Go's only loop keyword (lesson 16).
10. When you range over a map, in what order are the entries visited?
Sort the keys, for example with slices.Sorted(maps.Keys(m)), when order matters (lesson 17).
11. a := []int{1, 2, 3}; b := a[0:2]; b[0] = 9 — what is a now?
Slicing doesn't copy; both slices share the same array (lessons 25 and 26).
12. Why must you write s = append(s, x) instead of just append(s, x)?
Ignoring the result is a compile error (lessons 25 and 26).
13. What does writing to a key of a nil map do?
Reading a nil map is fine, writing panics; create maps with make or a literal (lesson 28).
14. In what order do several deferred calls in one function run?
(lesson 34)
15. When are the arguments of a deferred call evaluated?
Defer a closure to read a variable's final value (lesson 34).
16. What does a method with a value receiver, func (c Counter) Inc(), change when it does c.n++?
Use a pointer receiver to modify the receiver (lesson 38).
17. How does a type declare that it implements an interface?
Interfaces are satisfied implicitly (lesson 40).
18. A function returns error and ends with var e *MyErr; return e. What does err == nil give the caller?
Return a literal nil for "no error" (lesson 40).
19. Which is the safe way to check whether v any holds a string?
The single-value form panics when the type is wrong (lesson 41).
20. What makes a name visible to other packages?
(lesson 43)
21. What does fmt.Errorf("loading: %w", err) do that %v doesn't?
(lesson 45)
22. When is it appropriate to use panic?
Ordinary failures are returned as errors (lesson 46).
23. What does the constraint in func Index[T comparable](s []T, v T) int allow?
(lesson 47)
24. What's new about methods in Go 1.27?
Interface methods still can't have type parameters (lesson 49).
25. In a range-over-func iterator, what should the iterator do when yield returns false?
(lesson 50)
26. What happens to running goroutines when main returns?
Use sync.WaitGroup or channels to wait (lesson 51).
27. Who should close a channel?
Sending on a closed channel panics (lesson 52).
28. How do you detect data races in Go?
(lesson 54)
29. Which date layout produces 2026-10-08?
Layouts are written with the reference time Mon Jan 2 15:04:05 MST 2006 (lesson 60).
30. What must an HTTP client do with every response it receives?
Unclosed bodies leak connections; HTTP error statuses aren't Go errors, so check them yourself (lesson 62).