3 ms·
Something as simple as allowing the use of multi-result calls in if statements would make a huge difference. Being able to write "if err := blah(); err != nil {
by dguaraglia 9y ago
Something as simple as allowing the use of multi-result calls in if statements would make a huge difference. Being able to write "if err := blah(); err != nil { ... }" is great (although it does kind of hide the original call.)
- seanpfeifer 9y agoThis is possible in Go right now. Use "if thing, err := blah(); err != nil { ... }". This is common for things like map access. See an example here https://play.golang.org/p/P3k5tgFLd2 https://play.golang.org/p/P3k5tgFLd2
- dguaraglia 9y agoWait! Is this a go 1.9 thing? I've been using 1.83 all this time.
- zimpenfish 9y agoI don't think it's a 1.9 thing - I've got code from 2017-02 which uses it (the quickest example I could find in my repos)
- dguaraglia 9y agoWTF? You are absolutely right. I could've sworn I had issues with this before. 25% of my irritation with Go just evaporated (the other 75% is how hard it is to run Delve, but I'll figure that out.)
- ngrilly 9y agoThis has been possible for years ;-)