{"categories":["Go"],"published":"2018-04-20 00:18:29","image_url":null,"height":"190","title":"panic() \u3059\u308b\u304b non-nil error \u304c\u8fd4\u3063\u305f\u3089\u30ed\u30fc\u30eb\u30d0\u30c3\u30af\u7528\u306e\u51e6\u7406\u3092\u5b9f\u884c\u3059\u308b\u30e6\u30fc\u30c6\u30a3\u30ea\u30c6\u30a3\u69cb\u9020\u4f53 Guard \u3092\u4f5c\u3063\u305f","description":"\u3053\u3093\u306a\u611f\u3058\u306b\u4f7f\u3046\u3002 package main import ( \"errors\" \"fmt\" ) func main() { fmt.Println(\"start\") if err := f(); err != nil { fmt.Println(err.Error()) } fmt.Println(\"end\") } func f() (err error) { fmt.Println(\"f() start\") g := &Guard{} defer func() { err = g.Rollback(recover()) }() g.Add(func() { fmt.Println(\"rol\u2026","version":"1.0","blog_title":"Humanity","author_url":"https://blog.hatena.ne.jp/tyru/","author_name":"tyru","html":"<iframe src=\"https://hatenablog-parts.com/embed?url=https%3A%2F%2Ftyru.hatenablog.com%2Fentry%2F2018%2F04%2F20%2F001829\" title=\"panic() \u3059\u308b\u304b non-nil error \u304c\u8fd4\u3063\u305f\u3089\u30ed\u30fc\u30eb\u30d0\u30c3\u30af\u7528\u306e\u51e6\u7406\u3092\u5b9f\u884c\u3059\u308b\u30e6\u30fc\u30c6\u30a3\u30ea\u30c6\u30a3\u69cb\u9020\u4f53 Guard \u3092\u4f5c\u3063\u305f - Humanity\" class=\"embed-card embed-blogcard\" scrolling=\"no\" frameborder=\"0\" style=\"display: block; width: 100%; height: 190px; max-width: 500px; margin: 10px 0px;\"></iframe>","blog_url":"https://tyru.hatenablog.com/","provider_name":"Hatena Blog","provider_url":"https://hatena.blog","url":"https://tyru.hatenablog.com/entry/2018/04/20/001829","width":"100%","type":"rich"}