modulepackage
0.0.0-20190618154400-c187cad55e67
Repository: https://github.com/lk4d4/debugmutex.git
Documentation: pkg.go.dev
# README
debugmutex
Mutex for debugging deadlocks. It can find non-obvious deadlocks in systems
with heavy sync.Mutex
usage. I found many deadlocks in Docker with it.
Usage
type Struct struct {
sync.Locker
}
func New() *Struct {
locker := &sync.Mutex{}
if os.Getenv("DEBUG") != "" {
// will crash program with traceback and file:line where deadlock is
// occured after five tries to acquire mutex with 1 second gap between.
locker = debugmutex.New(5, true)
}
return &Struct{Locker: locker}
}
For logging github.com/sirupsen/logrus
is used. You can set debug logging with
logrus.SetLevel(logrus.DebugLevel)
# Functions
New returns new debug mutex.