Re:What could Go wrong with a mutex
by iainmerrick on Wednesday November 03, 2021 @08:21AM
(#29093616)
Does Go still run defers at function exit rather than scope exit? Changing that would be a big improvement, although I guess they’d have to use a different keyword to avoid breaking compatibility.
[ Parent
| on HN ]
At function exit. You can of course always create an anonymous function to emulate a block like:
func() {
defer something()
...
}()
This basically has the same behavior as having a block there, but with the defer being called at the exit of that functions body.