Closed korjavin closed 7 years ago
You can recover from the panic with recover()
, like this:
func canOpenDB(filename string) (retval bool) {
defer func() {
retval = nil == recover()
}()
dbconn, err := bolt.Open(filename, os.ModePerm, &bolt.Options{Timeout: 1 * time.Second})
defer dbconn.Close()
return nil == err
}
It may work, thank you!
This one will panic, but I would like to have just an err like "wrong format"