What concurrency-related, code- or design-level problems do you repeatedly notice during code reviews or in existing code and libraries?
A few things that I notice:
time.Tickernot stopped: missing
- A type is programmed to be safe for usage from multiple goroutines concurrently, but its documentation doesn’t specify what methods may be called from what goroutines and when. (The default would be “any method may be called from any goroutine at any moment”, but for many types, this must be more specific, e. g. some methods must only be called sequentially from a single goroutine.)
- Related/overlapping with the previous: there is a
sync.Mutexfield in a struct but no comment mentioning which fields it should protect (especially if there are more than 1-2 of them, and it’s not obvious which of them are mutable and which are not) and why.
(This is a cross-post from Reddit.)