Skip to content

deferred-lock-after-lock

Default severity: error

Deferring Lock or RLock immediately after acquiring the same lock is almost always a typo for deferring Unlock or RUnlock and is likely to deadlock when the function returns.

mutex.Lock()
defer mutex.Lock()
mutex.Lock()
defer mutex.Unlock()