Re:Go: a nice language with an annoying personality
by kristianp on Friday January 18, 2013 @03:04AM
(#5077661)
Good point about having to change the "_, err :=". I have found I have had to cascade changes to ":=" in go programs. I guess it does reduce the pythony feel.
[ Parent
| on HN ]
Re:Go: a nice language with an annoying personality
by swdunlop on Friday January 18, 2013 @07:25AM
(#5078300)
The _, err cascade is a nuisance when refactoring; I have gotten into the habit of throwing a var err error at the top of any function with a number of possible error results -- it also makes a handy notation that "here there be glue code."
Of course, where there's "_, err = ...", "if err != nil" returns are rarely far behind. :)
Re:Go: a nice language with an annoying personality
by NateDad on Friday January 18, 2013 @08:10AM
(#5078429)
if you use the standard if _, err := foo(); err != nil {
then the err variable's scope is limited to the if statement (usually correct), and you can then move that if statement where ever you want and it will stay intact, and will not interfere with the external code.