Don't bother with the else. Just continue with your code outside a nested block since the if returns.
in this case, f is locally scoped to the if/else statement since it's assigned inside the if statement... Probably most of the time I would actually assign it outside the if statement and then check it/return and not have the rest of the code indented.
Yes, there's some of this:
if f, err := io.Open("foo.txt"); err != nil {
} else { }However, that's not really any more code than
try:
except IOError as e: Plus Go uses multiple returns everywhere, so you don't have to worry about errors being confused with actual data returned.It's pretty awesome.