Chapter 7
From first principles
Rebuild the tools you have been using.
By the end of this chapter you'll be able to
- What we are building
- Three layers, decided before any code
- The type and its rules
- The store
- Listing, which is where the work actually is
Lessons
Module: From first principles
Build your own CRUD API from scratch
Every backend job, in the end, asks for the same thing: create a record, read one, list many with a filter, change one, delete one.
Build your own CLI framework
Every tool you write grows a command line eventually, and most people reach straight for Cobra without ever knowing what it does.
Build your own JSON parser
JSON is the smallest grammar worth parsing properly.
Build your own key-value store: a write-ahead log and crash recovery
A map in memory is a key-value store until the process restarts.
Build your own on-disk index: pages and a B-tree
The key-value store in chapter fifty one has a limit it does not advertise: on startup it replays the whole log into a map, so the index lives in.
Build your own Redis: RESP over raw TCP
Everything you have written so far has spoken HTTP, which is a protocol somebody else parsed for you.
Build your own HTTP server, from a TCP socket
Chapter twenty one used net/http, which hides the protocol so completely that most web developers have never seen a request line.
Build your own Git
Git is the tool you use most and understand least.
Build your own reverse proxy and load balancer
Every production system has one of these in front of it, and most developers treat it as a configuration file somebody else wrote.
Build your own job queue
Chapter forty three used a queue.
Build your own test runner, and what go test really does
go test feels like magic in a way the rest of Go does not.
Chapter assignment
Finish every assignment in From first principles
Each lesson in this part ends with its own assignment, named for the leaderboard. Finish them in order.
See success criteriaLesson 1 takes ~20 min.
Start chapterSpot a typo? Have an idea?
Help us improve this chapter. One click opens a GitHub issue with this chapter's URL pre-filled — suggest a clearer wording, report a bug, or request a new lesson. The course keeps improving thanks to learners like you.
Suggest an improvement on GitHub