LoginSignup
0
0

More than 3 years have passed since last update.

Built-inなtryはpackageであればいいんじゃないか

Posted at

はじめに

物議を醸しているtryですが、xerrosのようにサードパティなpackageとして需要が高まってきたら本体に組み込んでいくということもできるんじゃないかなという思いの元作りました。

リポジトリ

使い方

package main

import (
    "log"

    "github.com/junpayment/gotry"
)

func main() {
    f := func() (v, x int, e error) {
        return 1, 2, nil
    }

    defer func() {
        err := recover()
        if err == nil {
            return
        }
    }()
    res := gotry.Try(f())
    log.Println(res)
}

以上

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0