From OOP to Go
summary
Walks through translating a Java logger to Go, shows the bug caused by embedded structs promoting methods but delegating to the inner logger so context is lost, and proves inheritance-style translation fails; replaces ad-hoc targets with an interface-based design using io.Writer, swaps a custom LoggingTarget for standard library types and demonstrates that 351 types already implement io.Writer, and builds a simple injectable Logger struct with a constructor that writes to STDOUT or files.
AI-written summary · about
chapters (17)
- 0:00Introduction and background
- 1:30Go basics and mindset shift
- 3:38Logging library in Java
- 4:41Structs and methods in Go
- 7:31Logger implementation in Go
- 8:33Extending logger with inheritance
- 9:36Embedded structs in Go
- 11:23Debugging embedded struct issues
- 13:30Why translation fails in Go
- 15:36Interfaces and design principles
- 17:21Solving redundancy with interfaces
- 19:27Logging target interface solution
- 21:33Using io.writer for logging
- 23:00Multiple logging targets
- 24:24Key mindset changes for Go
- 25:26Go is not OOP
- 25:48Next steps and conclusion
