Idiomatic Go Tricks
summary
Shows concrete Go patterns and copyable snippets: uses line of sight code layout and consistent defer usage for deterministic cleanup, demonstrates teardown-as-return where setup returns a cleanup function to be deferred (useful in tests), provides a startTimer that captures time and returns a stop closure used with defer, implements optional validation via type assertions, uses single-method interfaces and HandlerFunc in place of structs, offers a retry helper (attempts < 5 example) and a semaphore built from a buffered channel to limit concurrency (example: five goroutines).
AI-written summary · about
chapters (18)
- 0:00Intro
- 0:28About me
- 2:12Go code
- 5:33Bad line of sight
- 6:07Line of sight tips
- 8:23Function type alternatives for single method interfaces
- 9:14Log blocks
- 9:59Return teardown functions
- 11:30Good timing
- 12:37Discover interfaces
- 14:15Other ways to implement the interface
- 15:06Optional features
- 17:35Using simple mocks
- 21:11Retrying Delay between retries
- 22:08Empty struct implementations
- 23:33Semaphores
- 25:49Be obvious not clever
- 26:29How to become a native speaker








