What does this print?
var x intvar s stringfmt.Printf("%d %q", x, s)What this Go test measures, in short
This test checks whether you can predict what real Go code does: zero values, how slices share memory, when defer runs, how channels block, and why a nil pointer inside an interface isn't nil. It rewards knowing the runtime rules, not memorising the standard library.
All snippets assume Go 1.22 or later, inside func main with fmt imported. The questions are our own and not standardised against a population, so treat the result as a check on your knowledge, not a certification.
By What's Your IQ · Reviewed 4 Oct 2026- Format
- 15 predict-the-output questions, 4 options each
- Topics
- Basics, slices and maps, functions and defer, concurrency, interfaces
- Version
- Go 1.22+ (per-iteration loop variables)
- Language
- Designed at Google by Griesemer, Pike and Thompson; open-sourced 2009
A slice is a window onto an array
Each slice is a small header: a pointer, a length and a capacity. Two slices can look at the same array, until append runs out of room and quietly copies to a new one.
Works, but not how Go people write it
result, _ := strconv.Atoi(input)use(result)
n, err := strconv.Atoi(input)if err != nil { return fmt.Errorf("parse %q: %w", input, err)}use(n)Go has no exceptions. Ignoring err with _ hides failures; wrapping with %w adds context and keeps the original error checkable with errors.Is.
- Pike, R. (2012). Go at Google: Language design in the service of software engineering.
- The Go Authors. Go 1 and the future of Go programs.
- The Go Authors. (2022). Go 1.18 release notes.
- The Go Authors. (2024). Go 1.22 release notes.