Don't Be Clever About Concurrency
Advice Programs that modify data being simultaneously accessed by multiple goroutines must serialize such access. To serialize access, protect the data with channel operations or other synchronization primitives such as those in the sync and sync/atomic packages. If you must read the rest of this document to understand the behavior of your program, you are being too clever. Don’t be clever.
A dark-themed programming advice card explains how to safely synchronize data accessed by multiple goroutines using channels and the sync packages. The punchline is that overly clever code is discouraged: if the documentation is needed to understand the behavior, the program is already too clever. It is used as a reaction to complicated or overengineered technical solutions. EN: A dark-themed programming advice card explains how to safely synchronize data accessed by multiple goroutines using channels and the sync packages. The punchline is that overly clever code is discouraged: if the documentation is needed to understand the behavior, the program is already too clever. It is used as a reaction to complicated or overengineered technical solutions.
- @right_wing_dev_squads / 5412 2022-11-29
- Type
- image
- Size
- 800×630 · 74.1 KiB
- Mood
- sarcastic, instructive
- Language
- en
- Added