News for hackers. Stuff that matters.
Re:The ups and downs of porting 50k lines of C++ to Go (2015) by Arnavion on Thursday March 14, 2019 @03:39AM (#19387197)
It's also not even true, given that `if foo, err := bar(); err != nil {` is considered idiomatic over writing that over two lines.
Re:The ups and downs of porting 50k lines of C++ to Go (2015) by joshuak on Thursday March 14, 2019 @04:03AM (#19387288)
Both 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.

Re:The ups and downs of porting 50k lines of C++ to Go (2015) by reddit_clone on Thursday March 14, 2019 @10:06AM (#19389294)
They 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.