Concurrency model in use: Communicating Sequential Processes (CSP) it means you just write your process as a sequential code, i.e. forget about parallelism while coding. You don’t have shared state! Instead of sharing you communicate the data with other processes (over channels)
- Passing pointers to channels can cause race condition
- As channels work with copies of data, passing them large data chunks can cause performance issues
- Channels can create deadlocks
- Don’t use channels in front of naturally shared structures like caches or registries, because channels are about not sharing (i.e. the CSP concurrency model). - In such cases you need to use the sync and sync.atomic packages.
- Avoid changing two thing at a time
- Avoid blocking
- Avoid race conditions
- Use channels to avoid sharing state
- When channels don't work use sync package