I am attempting to unlock a mutex if it is locked. However, that produced a runtime error so I thought that I would use the recover method:
package main
import "sync"
func main() {
var l sync.Mutex
l.Lock()
l.Unlock()
defer func() {
if recover() != nil {
// the return result can be altered
// in a defer function call
}
}()
l.Unlock()
}
However, even with recover, I still get:
fatal error: sync: unlock of unlocked mutex