What concurrency-related problems do you repeatedly notice in Go code?

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.Ticker not stopped: missing defer tick.Stop()
  • 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.Mutex field 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.)

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.