Chapter 4
The standard library
Real programs with nothing but what ships with Go.
By the end of this chapter you'll be able to
- Reading a whole file
- Streaming line by line
- os.Open against os.Create
- Buffer your writes
- io.Copy, and the pattern it enables
Lessons
Module: The standard library
Files, streams and the io interfaces
Two interfaces carry most of Go's I/O, and you met them in chapter ten:.
net/http: a server with no framework
Go's standard library includes a production-grade HTTP server.
Talking to a database with database/sql
Go's database/sql is not an ORM.
Project: a URL shortener
Everything from Parts I to III in one finished program: an HTTP server, a database, concurrency, context, error design, tests.
Configuration, environment and secrets
A program that works on your laptop and nowhere else usually has its configuration hard-coded.
Building, cross compiling and shipping one binary
This is the chapter that explains why people who deploy Node sound envious when Go comes up.
Chapter assignment
Finish every assignment in The standard library
Each lesson in this part ends with its own assignment, named for the leaderboard. Finish them in order.
See success criteriaLesson 1 takes ~15 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