{"by":"dirteater_","descendants":1,"id":46963736,"kids":[46966269,47029594,46963737],"score":30,"text":"I&#x27;ve done this same println debugging thing so many times, along with some sed&#x2F;awk stuff to figure out which call was causing the issue. Now it&#x27;s a small Go package.<p>With some `runtime.Callers` I can usually find the spot by just swapping the existing Mutex or RWMutex for this one.<p>Sometimes I switch the<p><pre><code>  mu.Lock()\n  defer mu.Unlock()\n</code></pre>\nwith the LockFunc&#x2F;RLockFunc to get more detail<p><pre><code>  defer mu.LockFunc()()\n</code></pre>\nI almost always initialize it with `deadlog.New(deadlog.WithTrace(1))` and that&#x27;s plenty.<p>Not the most polished library, but it&#x27;s not supposed to land in any commit, just a temporary debugging aid. I find it useful.","time":1770745453,"title":"Show HN: Deadlog – almost drop-in mutex for debugging Go deadlocks","type":"story","url":"https://github.com/stevenctl/deadlog"}