add OptDo wrapper

This commit is contained in:
gutmet 2018-12-22 19:50:52 +01:00
parent 3ba00a035c
commit 76fabd44bb

View File

@ -96,6 +96,14 @@ func AskFor(question string) (string, error) {
}
}
func OptDo(err error, f func() error) error {
if err == nil {
return f()
} else {
return err
}
}
func IntMin(x, y int) int {
if x < y {
return x