← Course map

GO LEARNING PATH · 8 LESSONS

Standard library patterns

io.Reader and io.Writer, encoding/json, and testing without a framework.

  1. Two interfaces, one method each

    Write a function that works on a file, a string and a test buffer.

    3 min · Worked lesson

  2. Struct tags are the JSON schema

    Control field names, omit empties, and know what unmarshalling leaves untouched.

    3 min · Prediction challenge

  3. A Duration is a number of nanoseconds with a type

    Write a timeout without wondering what unit it is in.

    3 min · Prediction challenge

  4. Sorting by whatever you like

    Sort a slice of structs by two keys.

    3 min · Worked lesson

  5. Every blocking call should take a context

    Make a function that waits stop waiting when told to.

    3 min · Worked lesson

  6. http.Handler is one method, like Reader

    Serve /hello from an in-memory request, with no listen.

    3 min · Worked lesson

  7. strconv is how text becomes a number

    Parse a port with Atoi and reject anything outside 1…65535.

    3 min · Worked lesson

  8. image.Image is three methods, not a file

    Implement a solid-colour image the standard library will accept.

    3 min · Worked lesson