1. What does a Go build typically produce?
- Java bytecode
- A folder of interpreted scripts
- A single compiled binary
- A Docker image automatically
Show answer
Answer: A single compiled binary
Static binaries are easy to deploy.
Lesson: Why Go
26 questions from the Go (Golang) course, each with the correct answer and an explanation. Try to answer before you open the answer.
Answer: A single compiled binary
Static binaries are easy to deploy.
Lesson: Why Go
Answer: func main() in package main
package main + func main.
Lesson: Hello, World and the go Command
Answer: By starting its name with an uppercase letter
Capitalisation controls visibility.
Lesson: Modules and Packages
Answer: The empty string ""
Every type has a defined zero value.
Answer: for condition { ... }
for covers every loop form.
Lesson: Control Flow
Answer: Return an error value as the last result
Errors are values.
Answer: The key is not in the map, and v is the zero value
Comma-ok distinguishes missing from zero.
Lesson: Slices and Maps
Answer: It has a value receiver, so it modified a copy
Pointer receivers modify the original.
Lesson: Structs and Methods
Answer: By having all the interface's methods; no declaration is needed
Satisfaction is implicit.
Lesson: Interfaces
Answer: Types that support < and > comparisons
Constraints limit type parameters.
Lesson: Generics
Answer: %w
%w preserves the chain.
Lesson: Wrapping and Inspecting Errors
Answer: Last in, first out
Like a stack.
Lesson: defer, panic and recover
Answer: It produces duplicate log entries as the error moves up
Handle an error once.
Lesson: Designing Errors
Answer: No, you must wait explicitly, for example with a WaitGroup
Coordinate completion explicitly.
Lesson: Goroutines and WaitGroups
Answer: The channel being closed and drained
Close signals completion.
Lesson: Channels and Pipelines
Answer: A channel that is closed when the context is cancelled or times out
Select on Done to stop work.
Lesson: select, Timeouts and context
Answer: Concurrent access to the same memory with at least one write and no synchronisation
Use mutexes, atomics or channels.
Answer: The mux responds 405 Method Not Allowed
Method-aware routing since Go 1.22.
Lesson: HTTP Servers With net/http
Answer: Excludes the field from JSON encoding and decoding
Keep internal fields out of payloads.
Lesson: JSON With Struct Tags
Answer: Year-month-day, written using the reference date
Layouts use the reference time.
Lesson: Time and Formatting
Answer: Each case becomes a named subtest, so failures point to the exact case
Named, isolated cases.
Lesson: Table-Driven Tests
Answer: Code that compiles but is likely a bug
Static analysis for common mistakes.
Lesson: go vet
Answer: It enforces one standard style automatically, ending style debates
Consistency at zero cost.
Lesson: gofmt and Consistent Style
Answer: Under internal/
internal/ cannot be imported by other modules.
Answer: Stops accepting new connections and waits for in-flight requests to finish
Graceful draining.
Answer: Tests run with the -race flag in CI
Correct, synchronised, formatted.
Lesson: A Go Code Review Checklist