Specifically, I use defers to avoid this kind of code. Only need to unlock in one place if the lock encompasses the whole function.