debugging Go deadlocks
UPDATE: I made this into a small Go module: https://github.com/stevenctl/deadlog. It is a drop in replacement for sync.Mutex and sync.RWMutex, with the option to call the returned unlock closure if you want to track unreleased locks. Don’t run with this in production, it’s only for debugging deadlocks. Multiple times, I’ve had to debug deadlocks in some Go code. Even though Go’s -race flag when running tests can detect deadlocks, in my experience it hasn’t caught the ones that drive me crazy with flaky or fast tests (~500ms-2s). ...