How Should We Access Global Resources?
summary
Argues for replacing globals with an interface-backed context that declares only required parts of a server, implemented in Go so missing dependencies fail at compile time. Provides working GitHub code and a homegrown statically-typed context plus a linter enforces minimal interface to prevent over-declaration. Uses standard Go interfaces and context types, lets functions receive one combined context, enables easy mocking for tests, supports concurrent requests, and reports compile-time breaks when a callee adds a new resource.
AI-written summary · about
chapters (8)
- 0:00Introduction
- 1:15Why use Global variables
- 2:14Server objects
- 3:20Context
- 3:40Interfaces
- 5:17Dependencies
- 5:28One step simpler
- 6:12Conclusion
related talks
20m"Demystifying Context Values"
26mA Beginners Guide to Context
21mContextual Logging for Modern Go Applications
23mFrom JS to Go
46mSimplifying Scalable Cloud Application Development with Go
24mFinal Go panel - part 1
26mGo is Boring... And That's Fantastic!
46mWhy you can't use GO! (away from anti-patterns)
