GO LEARNING PATH · 14 LESSONS
Standard library patterns
io.Reader and io.Writer, encoding/json, and testing without a framework.
Two interfaces, one method each
Write a function that works on a file, a string and a test buffer.
3 min · Worked lesson
Struct tags are the JSON schema
Control field names, omit empties, and know what unmarshalling leaves untouched.
3 min · Prediction challenge
JSON v2: migrate behavior, not just imports
Compare null, empty and omitted JSON values before changing a public API.
3 min · Worked lesson
A Duration is a number of nanoseconds with a type
Write a timeout without wondering what unit it is in.
3 min · Prediction challenge
Sorting by whatever you like
Sort a slice of structs by two keys.
3 min · Worked lesson
Every blocking call should take a context
Make a function that waits stop waiting when told to.
3 min · Worked lesson
http.Handler is one method, like Reader
Serve /hello from an in-memory request, with no listen.
3 min · Worked lesson
strconv is how text becomes a number
Parse a port with Atoi and reject anything outside 1…65535.
3 min · Worked lesson
image.Image is three methods, not a file
Implement a solid-colour image the standard library will accept.
3 min · Worked lesson
Borrow bytes briefly; copy before their owner changes
Trace bytes.Buffer and Scanner views, then make retained results independent at a lifetime boundary.
3 min · Worked lesson
JSON presence: omitted, zero and null are different states
Choose omitempty, omitzero and request presence models from the endpoint contract.
3 min · Worked lesson
Strict JSON input: reject ambiguity before side effects
Separate JSON syntax acceptance, unknown-member policy and domain validation.
3 min · Worked lesson
Timers and cancellation: versioned semantics still need a single owner
Explain Stop/Reset behavior, timer ownership and why select is not a priority statement.
3 min · Worked lesson
Outgoing HTTP: reuse the client and bound the response, not just the dial
Own the client lifetime, close bodies and classify HTTP status separately from transport failure.
3 min · Worked lesson