Re:Go's race detector has a mutex blind spot
by prerok on Saturday August 02, 2025 @01:54PM
(#44769749)
It's tedious, I agree, but I found it easiest to just wrap it in an inline function defined and called there and then.
This alleviates all these problems of unlocks within if bodies at the cost of an indent (and maybe slight performance penalty).
It’s absolutely a go-specific problem from defer being function scoped. Which could be ignored if Unlock was idempotent but it’s not.