3 ms·
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.
by kristianp 14y ago
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.
- swdunlop 14y agoThe _, 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. :)
- NateDad 14y agoif 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.