Provides functionality to help you execute methods safely.
Installation
go get -u github.com/kenkyu392/go-safe
Usage
package main
import (
"log"
"github.com/kenkyu392/go-safe"
)
func main() {
// The panic that occurs in the function is automatically handled as an error.
if err := safe.Do(func() error {
// Do something...
return nil
}); err != nil {
log.Fatal(err)
}
}