5 ms·
It's also not even true, given that `if foo, err := bar(); err != nil {` is considered idiomatic over writing that over two lines.
by Arnavion 8y ago
It's also not even true, given that `if foo, err := bar(); err != nil {` is considered idiomatic over writing that over two lines.
- joshuak 8y agoBoth are idiomatic. I use the two line version. I don't like this form both for legibility, and the fact that it closes over the return value.
- reddit_clone 8y agoThey are not the same though. I got bitten by this recently (Go beginner). In the single line form, both foo and err are scope restricted to the if block. Found that out the hard way.