4 ms·
That code is odd (though I assume idiomatic Go). I'd much rather have block scoping with something like this: for _, lock := range locks { lock.Loc
by gaganyaan 5y ago
That code is odd (though I assume idiomatic Go). I'd much rather have block scoping with something like this:
for _, lock := range locks {
lock.Lock()
// Do something with lock
}
And I don't really do Go, but in Rust, if I wanted to lock some arbitrary list of locks for a whole function, it would just be something like this at the top:
let _ = locks.iter().map(|l| l.lock().unwrap()).collect::<Vec<_>>();