Writing Beautiful Packages in Go
summary
Advice for package design focuses on concrete choices: keep the exported API small and obvious, prefer single-method interfaces and use io.Writer over os.File so JSON marshaling works to buffers, files or HTTP responses, avoid implicit goroutines and let callers manage concurrency, make zero values useful instead of forcing constructors, accept an HTTP client and put context as the first arg, and run linters and formatters like metalinter & gofmt (example shown: a 93% go report card score).
AI-written summary · about
chapters (40)
- 0:00Intro
- 0:39What are we gonna talk about today
- 0:58What is a package
- 1:51Beautiful packages
- 2:40Motivation
- 3:23Keep it internal
- 3:51Web 20 movement
- 4:36Usercentered design
- 5:07Whos using the package
- 5:42Market vendor
- 5:59Packages
- 6:40Narrow types
- 7:10Writers
- 7:58Single method interfaces
- 9:27HTTP handlers
- 10:10Structure
- 11:31Test Data
- 12:20Use Multiple Go Files
- 13:11Leave Concurrency to Users
- 14:44First User
- 15:04TestDriven Development
- 16:12Be Similar
- 17:05Write Some Jokes
- 17:55Naming
- 18:42API Footprint
- 21:29Default Formats
- 22:11Avoid constructors
- 23:36Dont automatically add interfaces
- 24:26Shrink API footprint
- 24:57Method names
- 25:51HTTP client
- 26:35Context
- 26:50Global State
- 28:05Test
- 29:14Package names
- 30:07Project mascots
- 30:53Name that project
- 33:57Go report card
- 34:55Quality package
- 36:30Questions








