Hacker News new | past | comments | ask | show | jobs | submit login

I was never a fan of try. It's too magical and breaks the flow.

Far better to use something more explicit and controllable:

    f, err := os.Open(filename) onerr return 0, err
which is just syntactic sugar for:

    f, err := os.Open(filename)
    if err != nil {
        return 0, err
    }
also:

    err := DoSomething() onerr {
        fmt.PrintF("We got error %v\n", err)
        return 0, err
    }



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: