Go field guide

Small Go projects that teach a complete loop

Choose an exercise with a clear input, an observable result and an honest stopping point. Each project below can begin without a framework, a cloud account or a database.

Small Go projects that teach a complete loop

Project one: a command-line inspector

Read a text file named by a command-line argument and report a small summary, such as the number of lines. Decide what happens when the argument is missing, the file cannot be opened or the input contains a very long line. Close the file at the scope that owns it. Keep the calculation separate from command-line parsing so that a unit test can supply an in-memory reader. A clear error message and a non-success exit status are part of the interface, not optional decoration.

Official reference

Project two: a JSON report

Decode a small JSON document into a type with explicit fields and produce a plain-text report. Define how missing fields and unknown fields should behave before writing the happy path. Bound input size when the source is untrusted. Distinguish a malformed document from a well-formed document that violates your application rules. Keep example data local and non-sensitive. Do not paste access tokens or real customer records into a tutorial repository just to make the example seem realistic.

Official reference

Project three: an HTTP endpoint

Use the standard HTTP package to return a small JSON response. Choose one route, validate the method and input, and use a server with explicit timeout settings appropriate to the exercise. Check the error returned by the server. A working response in a browser is only one check: also request an unknown path, use an unsupported method and send malformed input. Avoid exposing this learning service to the public internet until deployment, authentication and resource limits are part of the design.

Official reference

Test without a live server

Use the HTTP testing helpers to call a handler with a request and inspect the recorded response. Check the status, content type and relevant body fields. A useful test describes behavior rather than echoing the implementation line by line. When the handler depends on a clock or a remote lookup, provide a small boundary that a test can control. Keep one manual command as a smoke check, but do not depend on a developer remembering it for every change.

Official reference

Publish a useful README

Explain what the program does, the required Go version, the command to run tests and one input/output example. State which parts are educational simplifications. If the project intentionally lacks authentication or persistence, say so. A reader should not have to infer production readiness from a polished screenshot. Include the source of any borrowed data or protocol description and respect its license. A small project with explicit limits is more useful than a broad demo with hidden assumptions.

Official reference

Choose the next change from evidence

Once the simple version is understandable, change one requirement: handle another input format, add a deadline or return a different report. Keep the previous behavior covered where it remains part of the contract. Resist adding concurrency, persistence and a deployment pipeline in the same iteration. Independent changes make errors easier to locate. Finish when the stated exercise works and its limits are documented; a tutorial does not need to grow into a miniature company platform.

Official reference

A small command checklist

go fmt ./...
go vet ./...
go test ./...

Run these commands in the intended module folder. Check your installed Go version and the official documentation when an option differs from an example.