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?

2. Which command runs the package in the current folder of a module?

3. What is the zero value of a string variable?

4. What does len("Café") return?

5. What does 7 / 2 evaluate to when both operands are int?

6. What do the constants in const ( A = iota; B; C ) equal?

7. Why does string(65) usually indicate a bug?

8. In a Go switch, what happens after a matching case's code runs?

9. How does Go write a "while" loop?

10. When you range over a map, in what order are the entries visited?

11. a := []int{1, 2, 3}; b := a[0:2]; b[0] = 9 — what is a now?

12. Why must you write s = append(s, x) instead of just append(s, x)?

13. What does writing to a key of a nil map do?

14. In what order do several deferred calls in one function run?

15. When are the arguments of a deferred call evaluated?

16. What does a method with a value receiver, func (c Counter) Inc(), change when it does c.n++?

17. How does a type declare that it implements an interface?

18. A function returns error and ends with var e *MyErr; return e. What does err == nil give the caller?

19. Which is the safe way to check whether v any holds a string?

20. What makes a name visible to other packages?

21. What does fmt.Errorf("loading: %w", err) do that %v doesn't?

22. When is it appropriate to use panic?

23. What does the constraint in func Index[T comparable](s []T, v T) int allow?

24. What's new about methods in Go 1.27?

25. In a range-over-func iterator, what should the iterator do when yield returns false?

26. What happens to running goroutines when main returns?

27. Who should close a channel?

28. How do you detect data races in Go?

29. Which date layout produces 2026-10-08?

30. What must an HTTP client do with every response it receives?