|
|
|
|
|
by TheDong
316 days ago
|
|
From the golang github org in non-toy code: 1. https://github.com/golang/tools/blob/f7d99c1a286d6ec8bd4516a... 2. https://github.com/golang/sync/blob/7fad2c9213e0821bd78435a9... There are dozens and dozens throughout the stdlib and other popular go code. The singleflight case is quite common, if you have: mu.Lock()
if something() {
mu.Unlock()
moreWorkThatDoesntWantMutex()
return
}
mu.Unlock()
most gophers use manual lock/unlocks to be able to unlock early in an 'if' before a 'return', and that comes up often enough that it really does happen.I see manual lock/unlock all the time, and semi-regularly run into deadlocks caused by it. Maybe you don't use any third-party open source libraries, in which case, good for you congrats. |
|